Repository navigation
fix(sql): preserve SELECT column order and deterministic JSON field output (#45) - #46
Merged
Merged
Conversation
…utput (#45) Ensure deterministic field order in SQL projections and JSON outputs. Replace random HashMap iteration in SharedMap and SQL evaluation with IndexMap and the RowLookup trait. Maintain pure engine throughput at 2.55M EPS and streaming pipeline throughput at 1.07M EPS. Update documentation, SVG diagrams, and MCP tool references according to ASD-STE100.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
…r to_json Update test_object_json_parity to verify that to_json preserves the input sequence of keys rather than sorting alphabetically.
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.
Summary
This pull request resolves #45. It ensures that SQL query outputs and JSON serializations preserve the exact column sequence declared in the
SELECTclause.Previously,
SharedMapusedstd::collections::HashMap, which iterates in arbitrary order. This caused non-deterministic JSON field ordering across query executions.We replaced non-deterministic map iteration with
indexmap::IndexMapand introduced the genericRowLookuptrait. The engine now guarantees deterministic column ordering while maintaining ultra-high throughput.Technical Changes
rekuiper-core):SharedMapto wrapArc<IndexMap<String, Value>>.to_hashmap(),From<HashMap>,From<IndexMap>).SchemaMaptrait to handle schema enforcement uniformly acrossHashMapandIndexMap.rekuiper-sql):RowLookuptrait forIndexMap,HashMap, andSharedMapto eliminate unnecessary map copies during expression evaluation.eval_select,eval_select_stateful, andeval_select_filteredto returnIndexMap<String, Value>matching the query projection sequence.preserve_orderfeature onserde_jsonto keep key sequence during JSON serialization.rekuiper-server,rekuiper-connectors):IndexMapdeterministically.rekuiper-mcp):test_sql_expressiontool documentation inREADME.mdanddocs/en_US/mcp/overview.mdto specify deterministic column ordering.docs/en_US/sqls/query_language_elements.mdfollowing ASD-STE100 guidelines.docs/en_US/public/diagrams/deterministic_field_order.svg.npm --prefix docs run build(41.52s, 0 errors).Performance Targets & Benchmark Results
Benchmarked on native ext4 following official benchmark specification (
TOKIO_WORKER_THREADS=1 RUSTFLAGS="-C target-cpu=native" cargo test --release -p rekuiper-server --test perf_throughput -- --nocapture --test-threads=1):test_pure_engine_throughput_prebuilt_records)test_high_throughput_streaming_pipeline)Compared to
origin/mainbaseline,curdemonstrates 12% to 129% higher pipeline throughput due to reduced map allocation overhead.Local CI Validation
All local checks executed and passed before commit:
cargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warningsrekuiper-coreandrekuiper-sql.cargo build -p kuiperdcargo test -p rekuiper-sql --test test_issue45_order(3/3 passed)npm --prefix docs run build