@@ -75,14 +75,12 @@ def _build_engine_config(
7575 prometheus_scrape_interval : int ,
7676 log_level : str ,
7777 streaming_engine : str ,
78- forward_unsupported_queries : bool ,
7978 controller_config_dir : str ,
8079 compress_json : bool ,
81- prometheus_server : str ,
80+ backend : dict ,
8281 http_port : int ,
8382 remote_write_port : int ,
8483 dump_precomputes : bool ,
85- query_language : str ,
8684 lock_strategy : str ,
8785 profile_query_engine : bool ,
8886 kafka_broker : str ,
@@ -96,37 +94,24 @@ def _build_engine_config(
9694 prometheus_scrape_interval: Prometheus scraping interval in seconds
9795 log_level: Logging level
9896 streaming_engine: 'arroyo' (Kafka ingest) or 'precompute' (HTTP remote write)
99- forward_unsupported_queries: Whether to forward unsupported queries to backend
10097 controller_config_dir: Directory containing inference_config.yaml and streaming_config.yaml
10198 compress_json: Whether incoming JSON is gzip-compressed (arroyo/Kafka only)
102- prometheus_server: Full Prometheus URL, e.g. http://host:9090
99+ backend: BackendConfig dict with type tag and backend-specific fields.
100+ For prometheus: {"type": "prometheus", "server": "http://...", ...}
101+ For clickhouse: {"type": "clickhouse", "url": "...", "database": "...", ...}
102+ For elastic_querydsl/elastic_sql: {"type": "...", "url": "...", "index": "...", ...}
103+ Must include "forward_unsupported_queries" key.
103104 http_port: Port for the query engine's HTTP API server
104105 remote_write_port: Port to listen on for Prometheus remote write (precompute only);
105106 should match streaming.remote_write.base_port in the Hydra config
106107 dump_precomputes: Whether to dump received precomputes to output_dir for debugging
107- query_language: 'PROMQL' → prometheus backend, 'SQL' → clickhouse backend
108108 lock_strategy: Lock strategy for SimpleMapStore ('global' or 'per-key')
109109 profile_query_engine: Whether to enable do_profiling in the engine
110110 kafka_broker: Kafka broker address, e.g. '10.10.1.1:9092' (arroyo only)
111111
112112 Returns:
113113 Dict matching the EngineConfig YAML schema
114114 """
115- # Map query_language to the backend type (determines PromQL vs SQL API)
116- if query_language .upper () == "PROMQL" :
117- backend : dict = {
118- "type" : "prometheus" ,
119- "server" : prometheus_server ,
120- "forward_unsupported_queries" : forward_unsupported_queries ,
121- }
122- else :
123- # SQL mode: use clickhouse backend with the same host as prometheus_server
124- backend = {
125- "type" : "clickhouse" ,
126- "url" : prometheus_server ,
127- "forward_unsupported_queries" : forward_unsupported_queries ,
128- }
129-
130115 # Ingest config depends on the streaming engine.
131116 # Both flink and arroyo produce to the same Kafka topic.
132117 if streaming_engine in ("arroyo" , "flink" ):
@@ -155,7 +140,7 @@ def _build_engine_config(
155140 "streaming_engine" : streaming_engine ,
156141 "do_profiling" : profile_query_engine ,
157142 "http_server" : {"port" : http_port },
158- "backend" : backend ,
143+ "backend" : backend , # already fully resolved by caller
159144 "store" : {"lock_strategy" : lock_strategy },
160145 "ingest" : ingest ,
161146 "precompute_engine" : {"dump_precomputes" : dump_precomputes },
@@ -217,13 +202,13 @@ def start(
217202 profile_query_engine : bool ,
218203 manual : bool ,
219204 streaming_engine : str ,
220- forward_unsupported_queries : bool ,
221205 controller_remote_output_dir : str ,
222206 compress_json : bool ,
223207 dump_precomputes : bool ,
224208 lock_strategy : str ,
225- query_language : str = "PROMQL" ,
226- ** kwargs ,
209+ backend_config : dict ,
210+ http_port : int ,
211+ remote_write_port : int = 8080 ,
227212 ) -> None :
228213 """
229214 Start the Rust query engine.
@@ -239,29 +224,18 @@ def start(
239224 profile_query_engine: Whether to enable profiling
240225 manual: Whether to run in manual mode
241226 streaming_engine: Type of streaming engine ('arroyo' or 'precompute')
242- forward_unsupported_queries: Whether to forward unsupported queries
243227 controller_remote_output_dir: Controller output directory
244228 compress_json: Whether JSON is compressed (arroyo/Kafka only)
245229 dump_precomputes: Whether to dump precomputed values
246230 lock_strategy: Lock strategy for SimpleMapStore (global or per-key)
247- query_language: Query language (SQL or PROMQL), defaults to PROMQL
248- **kwargs: Additional configuration.
249- Required: prometheus_port, http_port.
250- Optional: prometheus_host (defaults to coordinator node IP),
251- remote_write_port (port the precompute engine listens on
252- for Prometheus remote write; should match
253- streaming.remote_write.base_port, defaults to 8080).
231+ backend_config: Fully resolved BackendConfig dict with type tag and all
232+ backend-specific fields (url/server/database/index as needed)
233+ plus forward_unsupported_queries. Matches the BackendConfig
234+ tagged union in asap-query-engine/src/engine_config.rs.
235+ http_port: Port for the query engine's HTTP API server
236+ remote_write_port: Port the precompute engine listens on for Prometheus remote
237+ write; should match streaming.remote_write.base_port (default 8080)
254238 """
255- # Extract prometheus configuration
256- prometheus_host = kwargs .get (
257- "prometheus_host" , self .provider .get_node_ip (self .node_offset )
258- )
259- prometheus_port = kwargs ["prometheus_port" ] # Required, no default
260- http_port = kwargs ["http_port" ] # Required, no default
261- # Port the precompute engine listens on for Prometheus remote write.
262- # Should match streaming.remote_write.base_port in the Hydra config.
263- remote_write_port = kwargs .get ("remote_write_port" , 8080 )
264-
265239 if self .use_container :
266240 self ._start_containerized (
267241 experiment_output_dir ,
@@ -272,15 +246,12 @@ def start(
272246 profile_query_engine ,
273247 manual ,
274248 streaming_engine ,
275- forward_unsupported_queries ,
276249 controller_remote_output_dir ,
277250 compress_json ,
278- prometheus_host ,
279- prometheus_port ,
251+ backend_config ,
280252 http_port ,
281253 remote_write_port ,
282254 dump_precomputes ,
283- query_language ,
284255 lock_strategy ,
285256 )
286257 else :
@@ -293,15 +264,12 @@ def start(
293264 profile_query_engine ,
294265 manual ,
295266 streaming_engine ,
296- forward_unsupported_queries ,
297267 controller_remote_output_dir ,
298268 compress_json ,
299- prometheus_host ,
300- prometheus_port ,
269+ backend_config ,
301270 http_port ,
302271 remote_write_port ,
303272 dump_precomputes ,
304- query_language ,
305273 lock_strategy ,
306274 )
307275
@@ -315,15 +283,12 @@ def _start_bare_metal(
315283 profile_query_engine : bool ,
316284 manual : bool ,
317285 streaming_engine : str ,
318- forward_unsupported_queries : bool ,
319286 controller_remote_output_dir : str ,
320287 compress_json : bool ,
321- prometheus_host : str ,
322- prometheus_port : int ,
288+ backend_config : dict ,
323289 http_port : int ,
324290 remote_write_port : int ,
325291 dump_precomputes : bool ,
326- query_language : str ,
327292 lock_strategy : str ,
328293 ) -> None :
329294 """Start Rust QueryEngine using bare metal deployment."""
@@ -336,14 +301,12 @@ def _start_bare_metal(
336301 prometheus_scrape_interval = prometheus_scrape_interval ,
337302 log_level = log_level ,
338303 streaming_engine = streaming_engine ,
339- forward_unsupported_queries = forward_unsupported_queries ,
340304 controller_config_dir = controller_remote_output_dir ,
341305 compress_json = compress_json ,
342- prometheus_server = f"http:// { prometheus_host } : { prometheus_port } " ,
306+ backend = backend_config ,
343307 http_port = http_port ,
344308 remote_write_port = remote_write_port ,
345309 dump_precomputes = dump_precomputes ,
346- query_language = query_language ,
347310 lock_strategy = lock_strategy ,
348311 profile_query_engine = profile_query_engine ,
349312 kafka_broker = f"{ self .provider .get_node_ip (self .node_offset )} :9092" ,
@@ -382,15 +345,12 @@ def _start_containerized(
382345 profile_query_engine : bool ,
383346 manual : bool ,
384347 streaming_engine : str ,
385- forward_unsupported_queries : bool ,
386348 controller_remote_output_dir : str ,
387349 compress_json : bool ,
388- prometheus_host : str ,
389- prometheus_port : int ,
350+ backend_config : dict ,
390351 http_port : int ,
391352 remote_write_port : int ,
392353 dump_precomputes : bool ,
393- query_language : str ,
394354 lock_strategy : str ,
395355 ) -> None :
396356 """Start Rust QueryEngine using containerized deployment with Jinja template."""
@@ -409,14 +369,12 @@ def _start_containerized(
409369 prometheus_scrape_interval = prometheus_scrape_interval ,
410370 log_level = log_level ,
411371 streaming_engine = streaming_engine ,
412- forward_unsupported_queries = forward_unsupported_queries ,
413372 controller_config_dir = container_controller_dir ,
414373 compress_json = compress_json ,
415- prometheus_server = f"http:// { prometheus_host } : { prometheus_port } " ,
374+ backend = backend_config ,
416375 http_port = http_port ,
417376 remote_write_port = remote_write_port ,
418377 dump_precomputes = dump_precomputes ,
419- query_language = query_language ,
420378 lock_strategy = lock_strategy ,
421379 profile_query_engine = profile_query_engine ,
422380 kafka_broker = f"{ self .provider .get_node_ip (self .node_offset )} :9092" ,
0 commit comments