SQL's query-requirements derivation (statistic mapping, grouping labels, data range) exists as three separate, non-shared implementations that happen to agree today but have no mechanism keeping them in sync:
asap-query-engine's main path (build_spatiotemporal_context, asap-query-engine/src/engines/simple_engine/sql.rs) derives query_output_labels, statistic_to_compute, and timestamps directly from SQLQueryData/SQLQuery, without going through QueryRequirements at all.
asap-query-engine's capability-matching fallback path calls build_query_requirements_sql, a private SimpleEngine method used only there.
asap-planner-rs's SQLSingleQueryProcessor::get_streaming_aggregation_configs (asap-planner-rs/src/planner/sql.rs) has its own from-scratch get_sql_treatment_type/get_sql_statistics, sharing no code with either function above.
Concretely: parse_single_statistic (query-engine, via AggregationOperator::to_statistics()) and get_sql_statistics (planner-rs, a hand-written match name.to_uppercase()) encode the same name→Vec<Statistic> mapping as two separately-maintained match statements. get_sql_treatment_type (planner-rs: "MIN"|"MAX" => Exact, _ => Approximate) happens to agree with what Statistic::is_approximate() would say for every statistic SQL can produce, but is a separate hand-written check, not a call to that method.
This is the same shape of problem #508 fixed for PromQL, which now has one canonical build_query_requirements_promql shared across all 4 of its own call sites (query-engine's main + fallback paths, planner's SingleQueryProcessor + AQE extractor). For SQL it's three-way, and unlike PromQL there's no cross-crate-shared function to converge onto yet — build_query_requirements_sql is private to asap-query-engine, not exported via asap_types the way PromQL's equivalent is.
SQL's query-requirements derivation (statistic mapping, grouping labels, data range) exists as three separate, non-shared implementations that happen to agree today but have no mechanism keeping them in sync:
asap-query-engine's main path (build_spatiotemporal_context,asap-query-engine/src/engines/simple_engine/sql.rs) derivesquery_output_labels,statistic_to_compute, and timestamps directly fromSQLQueryData/SQLQuery, without going throughQueryRequirementsat all.asap-query-engine's capability-matching fallback path callsbuild_query_requirements_sql, a privateSimpleEnginemethod used only there.asap-planner-rs'sSQLSingleQueryProcessor::get_streaming_aggregation_configs(asap-planner-rs/src/planner/sql.rs) has its own from-scratchget_sql_treatment_type/get_sql_statistics, sharing no code with either function above.Concretely:
parse_single_statistic(query-engine, viaAggregationOperator::to_statistics()) andget_sql_statistics(planner-rs, a hand-writtenmatch name.to_uppercase()) encode the same name→Vec<Statistic>mapping as two separately-maintained match statements.get_sql_treatment_type(planner-rs:"MIN"|"MAX" => Exact, _ => Approximate) happens to agree with whatStatistic::is_approximate()would say for every statistic SQL can produce, but is a separate hand-written check, not a call to that method.This is the same shape of problem #508 fixed for PromQL, which now has one canonical
build_query_requirements_promqlshared across all 4 of its own call sites (query-engine's main + fallback paths, planner'sSingleQueryProcessor+ AQE extractor). For SQL it's three-way, and unlike PromQL there's no cross-crate-shared function to converge onto yet —build_query_requirements_sqlis private toasap-query-engine, not exported viaasap_typesthe way PromQL's equivalent is.