Repository navigation
refactor(query-engine): add Scalar and Table QueryResult variants - #938
milindsrivastava1997 wants to merge 1 commit into
Conversation
QueryResult gains Scalar (one timestamped value) and Table {columns,
rows}. Response adapters format what their protocol can express and
error on the rest: Prometheus formats Scalar as resultType "scalar" and
rejects Table; ClickHouse (TSV) and Elastic (hits) format Table and
return NOT_IMPLEMENTED for Scalar, as they do for Matrix. A table whose
rows don't match its columns is a 500, not silently truncated.
Nothing produces the new variants yet. Exhaustive test matches gain a
panic arm for them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Code reviewImportant
Nits Pre-existing / latent 🤖 Generated with Claude Code |
Plan step 3 of
.design_docs/asapplanner-engine-boundaries.md, stacked on #937 (step 2) and #936 (step 1).Change
QueryResultgainsScalar(Sample), one timestamped value (the PromQL scalar), andTable(Table { columns, rows }), where cells areTableValue::{String, Float}.Table::is_rectangular()checks that every row has one value per column.QueryResultType(promql_utilities) gainsScalarandTable, soQueryResult::result_type()stays total.convert_query_result_to_prometheus){"resultType":"scalar","result":[ts,"v"]}convert_range_result_to_prometheus)_sourcekeyed by columnA non-rectangular
Tablereturns a 500 from ClickHouse and Elastic; it is never formatted after silently truncating or padding rows.Scope choices to review
Scalarrather than erroring. It is a native Prometheus result type, the formatting is fixed by the protocol, and new engines will produce it forscalar(...)and numeric literals. Erroring instead is a one-line change.String | Float. That covers today's SQL flattening (label values plus one value). Add more types when an engine produces them. The real cell types (ints, NULLs, bools from the executor's Arrow batches) are revisited when the executor result is converted toQueryResult, in the executorQueryEngine/ wiring steps.Behavior
No change: nothing produces
ScalarorTableyet, and theVector/Matrixpaths are untouched.Tests
Table(instant) andScalar/Table(range); ClickHouse and Elastic formatTable, return 500 for a ragged table, and return 501 forScalar.matches onQueryResult(stage_e_instant_range_equivalence_tests, onesimple_enginetest helper,e2e_precompute_equivalence) gain another => panic!(..)arm so they stay exhaustive. Their existing arms are untouched.cargo fmt,cargo clippy --workspace --all-targets --all-features -D warningsandcargo test --workspace --lockedpass: 1546 passed (1537 + 9).🤖 Generated with Claude Code