Skip to content

Stabilize query ordering and template column pagination - #18900

Open
Caideyipi wants to merge 2 commits into
apache:masterfrom
Caideyipi:fix/preserve-group-by-tag-order-master
Open

Caideyipi wants to merge 2 commits into
apache:masterfrom
Caideyipi:fix/preserve-group-by-tag-order-master

Conversation

@Caideyipi

@Caideyipi Caideyipi commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Description

GROUP BY TAGS queries can emit groups in different orders across DataNodes because tag-group maps lose their encounter order during analysis, logical planning, and plan deserialization. Template wildcard expansion also depends on map iteration order that can change after template serialization, causing inconsistent output columns and SLIMIT/SOFFSET selections.

  • Preserve tag-group encounter order throughout analysis, plan construction, and deserialization.
  • Expand template wildcards in measurement-name order before applying column pagination, for raw queries, aggregation queries, and schema-tree traversal. Reuse each ordered template snapshot across devices within a schema-tree visitor.
  • Apply SLIMIT/SOFFSET to explicit measurements, aggregations, and COUNT_TIME. Defer schema-tree offset traversal until template metadata is installed, support offset without a limit, and finish template queries early when pagination removes every output column.

Regression tests cover tag-group ordering, repeated template serialization with colliding measurement names, wildcard and explicit-column pagination, and empty projections with multiple devices.

Validation

  • Targeted DataNode suite: 37 tests, 0 failures, 0 errors, 2 pre-existing ignored tests. Covers the new GroupByTagPlanningOrderTest and TemplateQueryOrderTest, existing template retry and schema-tree tests, related plan-node serialization tests, and GROUP BY TAGS logical-planner tests.
  • mvn spotless:apply -pl iotdb-core/datanode passed.
  • DataNode test lifecycle passed, including Checkstyle scoped to all Java files changed in this PR, Spotless, compilation, and the related tests above.
  • Cluster integration tests were not rerun locally because of memory pressure from concurrent builds.

This PR has:

  • been self-reviewed.
  • added regression tests for the affected code paths.

@Caideyipi Caideyipi changed the title [TIMECHODB] Preserve GROUP BY TAGS group order after deserialization [TIMECHODB] Stabilize query ordering and template column pagination Oct 16, 2026
@Caideyipi Caideyipi changed the title [TIMECHODB] Stabilize query ordering and template column pagination Stabilize query ordering and template column pagination Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant