Repository navigation
refactor(query-engine): add Scalar and Table QueryResult variants - #938
Draft
milindsrivastava1997 wants to merge 1 commit into
Draft
milindsrivastava1997 wants to merge 1 commit into
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>
This was referenced Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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