@@ -20,8 +20,8 @@ use crate::StreamingEngine;
2020
2121pub struct SQLSingleQueryProcessor {
2222 query_string : String ,
23- t_repeat : u64 ,
24- data_ingestion_interval : u64 ,
23+ t_repeat_ms : u64 ,
24+ data_ingestion_interval_ms : u64 ,
2525 table_definitions : Vec < TableDefinition > ,
2626 #[ allow( dead_code) ]
2727 streaming_engine : StreamingEngine ,
@@ -33,17 +33,17 @@ impl SQLSingleQueryProcessor {
3333 #[ allow( clippy:: too_many_arguments) ]
3434 pub fn new (
3535 query_string : String ,
36- t_repeat : u64 ,
37- data_ingestion_interval : u64 ,
36+ t_repeat_ms : u64 ,
37+ data_ingestion_interval_ms : u64 ,
3838 table_definitions : Vec < TableDefinition > ,
3939 streaming_engine : StreamingEngine ,
4040 sketch_parameters : Option < SketchParameterOverrides > ,
4141 cleanup_policy : CleanupPolicy ,
4242 ) -> Self {
4343 Self {
4444 query_string,
45- t_repeat ,
46- data_ingestion_interval ,
45+ t_repeat_ms ,
46+ data_ingestion_interval_ms ,
4747 table_definitions,
4848 streaming_engine,
4949 sketch_parameters,
@@ -72,8 +72,12 @@ impl SQLSingleQueryProcessor {
7272 } ) ?;
7373
7474 // Match query to pattern
75- let sql_query = SQLPatternMatcher :: new ( schema. clone ( ) , self . data_ingestion_interval as f64 )
76- . query_info_to_pattern ( & qdata) ;
75+ // SQLPatternMatcher.scrape_interval is in seconds (SQL timestamps are seconds-based).
76+ let sql_query = SQLPatternMatcher :: new (
77+ schema. clone ( ) ,
78+ self . data_ingestion_interval_ms as f64 / 1000.0 ,
79+ )
80+ . query_info_to_pattern ( & qdata) ;
7781
7882 if !sql_query. is_valid ( ) {
7983 return Err ( ControllerError :: SqlParse ( sql_query. msg . unwrap_or_default ( ) ) ) ;
@@ -97,8 +101,11 @@ impl SQLSingleQueryProcessor {
97101 let value_column = agg_info. get_value_column_name ( ) . to_string ( ) ;
98102
99103 // Compute window
100- let window_cfg =
101- compute_sql_window ( query_type, self . data_ingestion_interval , self . t_repeat ) ;
104+ let window_cfg = compute_sql_window (
105+ query_type,
106+ self . data_ingestion_interval_ms ,
107+ self . t_repeat_ms ,
108+ ) ;
102109
103110 // Get all metadata columns for the table
104111 let all_metadata = get_all_metadata_columns ( & self . table_definitions , table_name) ?;
@@ -157,16 +164,17 @@ impl SQLSingleQueryProcessor {
157164 }
158165 }
159166
160- let t_lookback = match query_type {
161- QueryType :: Spatial => self . data_ingestion_interval ,
162- _ => sql_query. query_data [ 0 ] . time_info . get_duration ( ) as u64 ,
167+ let t_lookback_ms = match query_type {
168+ QueryType :: Spatial => self . data_ingestion_interval_ms ,
169+ // SQLPatternParser always produces second-based durations; convert to ms.
170+ _ => ( sql_query. query_data [ 0 ] . time_info . get_duration ( ) * 1000.0 ) . round ( ) as u64 ,
163171 } ;
164172
165173 let cleanup_param = if self . cleanup_policy == CleanupPolicy :: NoCleanup {
166174 None
167175 } else {
168176 Some (
169- get_sql_cleanup_param ( self . cleanup_policy , t_lookback , self . t_repeat )
177+ get_sql_cleanup_param ( self . cleanup_policy , t_lookback_ms , self . t_repeat_ms )
170178 . map_err ( ControllerError :: PlannerError ) ?,
171179 )
172180 } ;
@@ -215,16 +223,12 @@ fn get_sql_statistics(name: &str) -> Result<Vec<Statistic>, ControllerError> {
215223
216224fn compute_sql_window (
217225 query_type : & QueryType ,
218- data_ingestion_interval : u64 ,
219- t_repeat : u64 ,
226+ data_ingestion_interval_ms : u64 ,
227+ t_repeat_ms : u64 ,
220228) -> IntermediateWindowConfig {
221- // data_ingestion_interval and t_repeat are seconds (SQL mode is out of scope for the
222- // ms-precision rename, see issue #427) — IntermediateWindowConfig is now ms-typed
223- // throughout, so convert at this boundary, same as the pre-existing pattern in
224- // asap-query-engine/src/engines/simple_engine/sql.rs.
225229 let window_size_ms = match query_type {
226- QueryType :: Spatial => data_ingestion_interval * 1000 ,
227- _ => t_repeat * 1000 ,
230+ QueryType :: Spatial => data_ingestion_interval_ms ,
231+ _ => t_repeat_ms ,
228232 } ;
229233 IntermediateWindowConfig {
230234 window_size_ms,
0 commit comments