Skip to content

feat(statewindow): support multi columns#35136

Open
Tony2h wants to merge 28 commits into3.0from
feat/3.0/state
Open

feat(statewindow): support multi columns#35136
Tony2h wants to merge 28 commits into3.0from
feat/3.0/state

Conversation

@Tony2h
Copy link
Copy Markdown
Member

@Tony2h Tony2h commented Apr 14, 2026

Description

Issue(s)

Checklist

Please check the items in the checklist if applicable.

  • Is the user manual updated?
  • Are the test cases passed and automated?
  • Is there no significant decrease in test coverage?

@Tony2h Tony2h requested review from a team, dapan1121, guanshengliang and zitsen as code owners April 14, 2026 08:11
Copilot AI review requested due to automatic review settings April 14, 2026 08:11
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for multi-column state windows in TDengine, allowing users to define state windows based on the continuity of one or more state keys. The changes include updates to the SQL syntax, parser, planner, and executor to handle multiple state expressions, boundary extensions, and zero-state filtering. My feedback focuses on improving the robustness of null pointer checks in the executor and simplifying the error handling cleanup logic in the parser.

Comment on lines +1139 to +1141
if (pStateColInfoData == NULL || pStateColInfoData->pData == NULL ||
pKey == NULL || pKey->pData == NULL ||
!compareVal(colDataGetData(pStateColInfoData, rowIndex), pKey)) {

This comment was marked as resolved.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines +1872 to +1878
_err:
nodesDestroyNode((SNode*)state);
nodesDestroyList(pExprList);
nodesDestroyNode(pExtend);
nodesDestroyList(pZerothList);
nodesDestroyNode(pTrueForLimit);
return NULL;

This comment was marked as resolved.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends TDengine’s STATE_WINDOW to support multiple state keys (multi-column / multi-expr) across the SQL parser/AST, planner, executor, and stream notify payloads, and updates documentation + test expectations accordingly.

Changes:

  • Add multi-key STATE_WINDOW(state_expr[, ...]) support and introduce keyword-style options EXTEND(n) / ZEROTH_STATE(...) (with NO_ZEROTH), while keeping a restricted legacy positional form for single-column usage.
  • Propagate multi-key state window keys through planning/explain output and executor state-window aggregation logic.
  • Extend stream trigger deploy/msg/json formats and notify payload generation to handle multi-key state arrays; update docs and tests.

Reviewed changes

Copilot reviewed 52 out of 53 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/ci/cases.task Adds new StateWindow pytest cases to CI task list.
test/cases/18-StreamProcessing/05-Notify/test_stream_notify_state_multi.py New test validating multi-key state-window notify JSON payload semantics.
test/cases/13-TimeSeriesExt/04-StateWindow/test_state_window_null_block.py Updates state window tests to new EXTEND() syntax and adds multi-key + NULL-block coverage.
test/cases/13-TimeSeriesExt/04-StateWindow/test_state_window_extend.py Migrates extend tests from positional args to EXTEND(n) and updates negative-input checks.
test/cases/13-TimeSeriesExt/04-StateWindow/test_state_window.py Adds multi-key state-window expression tests, invalid-input tests, and multi-key zeroth-state coverage; updates old extend syntax usages.
test/cases/09-DataQuerying/15-Explain/r/test_explain.result Updates expected explain output wording to “StateWindow on Columns …”.
test/cases/05-VirtualTables/ans/test_vtable_plan_replace_tbname.ans Updates explain plan expectations for state-window wording changes.
test/cases/05-VirtualTables/ans/test_vtable_plan_eliminate_virtual_scan.ans Updates explain plan expectations for state-window wording changes.
test/cases/05-VirtualTables/ans/test_vstable_plan_test_window_state.ans Updates explain plan expectations for state-window wording changes.
source/libs/planner/test/planStateTest.cpp Expands planner tests for multi-arg/legacy state-window forms and multi-key expressions.
source/libs/planner/src/planPhysiCreater.c Switches physical node creation to carry a list of state keys instead of a single key.
source/libs/planner/src/planOptimizer.c Restricts certain vtable/vstable window optimizations to single-key state windows and adapts to list-based keys.
source/libs/planner/src/planLogicCreater.c Builds logic window nodes using a list of state expressions.
source/libs/parser/test/parStreamTest.cpp Adds parser tests for new keywords, legacy compatibility, ambiguity rejection; updates expected trigger state encoding to slot-id arrays.
source/libs/parser/test/parSelectTest.cpp Adds select-parser coverage for legacy and keyword state-window syntaxes and multi-key ambiguity errors.
source/libs/parser/src/parTranslater.c Implements multi-key state-window validation, legacy normalization, multi-key zeroth-state validation/casting, and updated stream trigger serialization.
source/libs/parser/src/parTokenizer.c Adds new keywords EXTEND, ZEROTH_STATE, NO_ZEROTH.
source/libs/parser/src/parAstCreater.c Adds NULL value-node helper and reworks state-window AST creation to hold expr/zeroth lists + extend node.
source/libs/parser/inc/sql.y Updates grammar for multi-key STATE_WINDOW(...) plus EXTEND(...) / ZEROTH_STATE(...) options and NO_ZEROTH list parsing.
source/libs/parser/inc/parAst.h Updates state-window AST creator signature and adds createNullValueNode.
source/libs/nodes/test/nodesCloneTest.cpp Updates node clone tests for list-based state-window expressions.
source/libs/nodes/src/nodesUtilFuncs.c Updates node destruction to free state expr/zeroth lists and planner window state expr list.
source/libs/nodes/src/nodesTraverseFuncs.c Updates traversal/rewriting to walk/rewrite state expr/zeroth lists plus extend.
source/libs/nodes/src/nodesMsgFuncs.c Updates state-window physical node TLV encoding/decoding to use node lists for keys.
source/libs/nodes/src/nodesCodeFuncs.c Updates JSON (de)serialization keys for list-based state expr/keys and state-window AST fields.
source/libs/nodes/src/nodesCloneFuncs.c Updates clone logic for list-based state expr/zeroth fields in AST and logic window nodes.
source/libs/new-stream/src/streamUtil.c Adds multi-key state notify JSON builder using arrays for prev/cur/next states; refactors JSON value creation helpers.
source/libs/new-stream/inc/streamTriggerTask.h Extends trigger task structures to store multi-slot IDs and multi-state values (while keeping single-key fast paths).
source/libs/new-stream/inc/streamInt.h Exposes streamBuildMultiStateNotifyContent API.
source/libs/executor/test/queryPlanTests.cpp Updates test plan node generator to create lists of state keys.
source/libs/executor/src/timewindowoperator.c Implements multi-key state-window aggregation: per-row NULL detection across keys, key assignment/compare across multiple columns, and cleanup/reset updates.
source/libs/executor/inc/executorInt.h Updates operator info struct to store arrays of state columns/keys.
source/libs/command/src/explain.c Formats multi-key state-window explain output with comma-separated key names and truncation.
source/libs/command/inc/commandInt.h Updates explain format string and adds reserved-size constant for state-key description.
source/dnode/mnode/impl/src/mndStreamUtil.c Updates state-trigger logging to reflect slot-id arrays.
source/common/src/msg/streamMsg.c Introduces backward-compatible v1/v2 binary encoding for state trigger slot IDs using a sentinel for multi-slot payloads; updates free/clone paths.
source/common/src/msg/streamJson.c Updates state-trigger JSON encoding/decoding to support slotIds array (and keep slotId for compatibility).
include/libs/nodes/querynodes.h Changes SStateWindowNode to store pExprList and pZerothList (and keep pExtend).
include/libs/nodes/plannodes.h Changes planner nodes to store state expr/key lists.
include/common/streamMsg.h Changes state trigger payload from single slotId to pSlotIds array and introduces v2 sentinel constant.
docs/zh/14-reference/03-taos-sql/41-stream.md Documents multi-key state-window triggers, keyword options, and notify payload differences for multi-key states.
docs/zh/14-reference/03-taos-sql/24-distinguished.md Updates STATE_WINDOW syntax/docs to multi-key + keyword options; adds examples and clarifies NULL semantics.
docs/zh/14-reference/03-taos-sql/20-select.md Updates SELECT window-clause docs for multi-key state windows and new options.
docs/zh/06-advanced/03-stream.md Updates advanced stream docs to reflect multi-key state windows and new syntax.
docs/zh/05-basic/03-query.md Updates introductory query/window docs for multi-key state windows and new syntax.
docs/en/14-reference/03-taos-sql/41-stream.md English docs update for multi-key state-window triggers, syntax, and notify payload.
docs/en/14-reference/03-taos-sql/24-distinguished.md English docs update for multi-key state windows, syntax, examples, and NULL semantics.
docs/en/14-reference/03-taos-sql/20-select.md English SELECT docs update for multi-key state windows and options.
docs/en/06-advanced/03-stream.md English advanced stream docs update for multi-key state windows.
docs/en/05-basic/03-query.md English basic query docs update for multi-key state-window description and syntax/examples.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/ci/cases.task
Copilot AI review requested due to automatic review settings April 16, 2026 11:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends TDengine’s STATE_WINDOW feature to support multiple state keys (columns/expressions), introduces keyword options (EXTEND(...), ZEROTH_STATE(...), NO_ZEROTH), and updates planner/executor/stream-trigger plumbing plus tests and docs to match the new behavior.

Changes:

  • Parser/AST/translator updates to accept multi-key STATE_WINDOW(k1, k2, ...) plus keyword options, while keeping legacy positional syntax for single-column STATE_WINDOW(col[, extend[, zeroth]]).
  • Planner/executor updates to carry lists of state keys through logical/physical plans and evaluate multi-key window boundaries and NULL-handling.
  • Stream trigger/message/notify payload updates to support multi-key state transitions (arrays) and backward-compatible serialization formats; adds/updates test coverage and documentation.

Reviewed changes

Copilot reviewed 66 out of 67 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/new_test_framework/utils/compatibilityUtil.py Adds stopTaosdCompletely() helper and adjusts logging used by compatibility tests.
test/ci/cases.task Adds new CI entries for state-window zeroth/multi-col tests.
test/cases/18-StreamProcessing/23-Compatibility/test_new_stream_compatibility.py Updates compatibility stream test to use enterprise installs and CLI-based verification.
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_rolling_upgrade_all.py Switches from killAllDnodes() to tdCb.stopTaosdCompletely().
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_cross_version.py Removes local kill helpers and uses shared tdCb.stopTaosdCompletely().
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_backward_forward_part4.py Replaces killAllDnodes() with stopTaosdCompletely().
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_backward_forward_part3.py Replaces killAllDnodes() with stopTaosdCompletely().
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_backward_forward_part2.py Replaces killAllDnodes() with stopTaosdCompletely().
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_backward_forward_part1.py Replaces killAllDnodes() with stopTaosdCompletely().
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_backward_forward.py Replaces killAllDnodes() with stopTaosdCompletely().
test/cases/18-StreamProcessing/05-Notify/test_stream_notify_state_multi.py New system test validating multi-key state notify payloads (arrays + JSON null handling).
test/cases/13-TimeSeriesExt/04-StateWindow/test_state_window_null_block.py Updates syntax to extend() keyword form and adds multi-key NULL-block validation.
test/cases/13-TimeSeriesExt/04-StateWindow/test_state_window_extend.py Updates legacy state_window(s, n) to state_window(s) extend(n) and adjusts error cases.
test/cases/13-TimeSeriesExt/04-StateWindow/test_state_window.py Adds multi-key expr/zeroth/invalid tests and updates legacy extend usage.
test/cases/09-DataQuerying/15-Explain/r/test_explain.result Updates explain output wording (“Column” → “Columns”) for state window nodes.
test/cases/09-DataQuerying/08-SubQuery/ans/test_scalar_sub_query2.0.csv Updates expected failures for subquery usage inside STATE_WINDOW.
test/cases/09-DataQuerying/08-SubQuery/ans/test_quantified_sub_query4.0.csv Adjusts expected error spans for quantified subquery expressions in STATE_WINDOW.
test/cases/09-DataQuerying/08-SubQuery/ans/test_in_sub_query2.0.csv Adjusts expected error spans for IN subquery expressions in STATE_WINDOW.
test/cases/05-VirtualTables/ans/test_vtable_plan_replace_tbname.ans Updates explain/error expectations for state window plans after syntax/behavior changes.
test/cases/05-VirtualTables/ans/test_vtable_plan_eliminate_virtual_scan.ans Updates explain output wording for state window nodes.
source/util/src/tjson.c Adds tjsonIsArray() helper.
include/util/tjson.h Declares tjsonIsArray().
source/libs/planner/test/planStateTest.cpp Adds planner tests for legacy positional and multi-key state window expressions.
source/libs/planner/src/planPhysiCreater.c Switches state key handling from single node to list (pStateKeys).
source/libs/planner/src/planOptimizer.c Restricts certain vtable optimizations to single-key state windows; updates state expr access.
source/libs/planner/src/planLogicCreater.c Switches logical window state expression field to list form (pStateExprs).
source/libs/parser/test/parStreamTest.cpp Adds tests for keyword syntax and multi-key trigger slot list serialization expectations.
source/libs/parser/test/parSelectTest.cpp Adds select parsing tests for keyword options, multi-key usage, and invalid mixes.
source/libs/parser/src/parTranslater.c Normalizes legacy syntax, validates multi-key rules, enforces “must reference column”, and updates create-stream trigger encoding.
source/libs/parser/src/parTokenizer.c Adds keywords: EXTEND, ZEROTH_STATE, NO_ZEROTH.
source/libs/parser/src/parAstCreater.c Implements list-based state window AST and createNullValueNode() for NO_ZEROTH.
source/libs/parser/inc/sql.y Updates grammar for multi-key state window keys and keyword options.
source/libs/parser/inc/parAst.h Updates createStateWindowNode signature and declares createNullValueNode().
source/libs/nodes/test/nodesCloneTest.cpp Updates node clone tests for list-based state window keys.
source/libs/nodes/src/nodesUtilFuncs.c Updates destroy logic for state-window lists and plan nodes using state expr/key lists.
source/libs/nodes/src/nodesTraverseFuncs.c Updates traversal/rewriter paths to walk state expr/key lists + extend/zeroth lists.
source/libs/nodes/src/nodesMsgFuncs.c Encodes/decodes physical state keys as node lists.
source/libs/nodes/src/nodesCodeFuncs.c Adds JSON compat for state expr/key list fields; extends nodesStringToList to accept legacy JSON object format.
source/libs/nodes/src/nodesCloneFuncs.c Clones new list fields (pExprList, pZerothList, pStateExprs).
include/libs/nodes/querynodes.h Updates SStateWindowNode to list-based representation (pExprList, pZerothList).
include/libs/nodes/plannodes.h Updates planner nodes for list-based state expr/keys.
source/libs/new-stream/src/streamUtil.c Adds multi-key state notify JSON builder producing arrays for state payloads.
source/libs/new-stream/inc/streamInt.h Declares streamBuildMultiStateNotifyContent().
source/libs/new-stream/inc/streamTriggerTask.h Updates trigger task state-window fields to store slot-id arrays + node lists.
source/libs/executor/test/queryPlanTests.cpp Updates executor plan test generator to create state key lists.
source/libs/executor/src/timewindowoperator.c Implements multi-key state window execution (NULL check, key assignment/compare, cleanup).
source/libs/executor/inc/executorInt.h Updates operator info to store arrays of state columns/keys.
source/libs/command/src/explain.c Adds helper to format multi-key state window descriptions and updates output formatting.
source/libs/command/inc/commandInt.h Updates explain format string to “Columns” and adds reserved buffer size constant.
source/dnode/mnode/impl/src/mndStreamUtil.c Updates stream trigger logging to report slot-id list size/first element.
include/common/streamMsg.h Updates state trigger struct to store slot-id arrays and defines v2 sentinel for deploy encoding.
source/common/src/msg/streamMsg.c Adds backward-compatible binary encoding/decoding for multi-slot state triggers; frees slot-id arrays.
source/common/src/msg/streamJson.c Adds backward-compatible JSON encoding/decoding for state trigger slot-id arrays.
docs/zh/14-reference/03-taos-sql/41-stream.md Documents multi-key state-window trigger syntax and multi-key notify payload behavior.
docs/zh/14-reference/03-taos-sql/24-distinguished.md Documents multi-key state window syntax/options and updated NULL semantics explanation.
docs/zh/14-reference/03-taos-sql/20-select.md Updates SELECT window clause docs for new state window syntax and options.
docs/zh/06-advanced/03-stream.md Updates advanced stream docs to reflect multi-key state-window triggers.
docs/zh/05-basic/03-query.md Updates basic query docs to reflect multi-key state windows and new syntax.
docs/en/14-reference/03-taos-sql/41-stream.md English docs: multi-key state-window triggers + notify payload arrays.
docs/en/14-reference/03-taos-sql/24-distinguished.md English docs: multi-key state window syntax/options and semantics.
docs/en/14-reference/03-taos-sql/20-select.md English docs: SELECT window clause updated for multi-key state windows.
docs/en/06-advanced/03-stream.md English advanced stream docs updated for multi-key state-window triggers.
docs/en/05-basic/03-query.md English basic query docs updated for multi-key state windows and syntax.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/new_test_framework/utils/compatibilityUtil.py Outdated
Comment thread test/new_test_framework/utils/compatibilityUtil.py Outdated
Copilot AI review requested due to automatic review settings April 20, 2026 03:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends TDengine’s STATE_WINDOW support to handle multiple state keys, updating the parser/AST, planner, executor, stream trigger encoding, notify payloads, tests, and documentation to reflect the new syntax and behaviors.

Changes:

  • Add multi-key STATE_WINDOW(k1, k2, ...) support across parser → planner → executor, plus explain output updates.
  • Update stream trigger infrastructure to carry multiple slot IDs and emit array-form state notify payloads.
  • Expand/adjust test coverage and docs for new EXTEND(...) / ZEROTH_STATE(...) clause-style options and multi-key semantics.

Reviewed changes

Copilot reviewed 69 out of 70 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/new_test_framework/utils/compatibilityUtil.py Replace grep-based PID detection and add stopTaosdCompletely() helper for compatibility tests.
test/ci/cases.task Add CI entries for new StateWindow test cases.
test/cases/18-StreamProcessing/23-Compatibility/test_new_stream_compatibility.py Refactor compatibility flow to use enterprise installs, new stop helper, and CLI-based stream checks.
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_rolling_upgrade_all.py Switch dnode shutdown to stopTaosdCompletely().
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_cross_version.py Use shared tdCb.stopTaosdCompletely() and remove duplicated process helpers.
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_backward_forward_part4.py Switch dnode shutdown to stopTaosdCompletely().
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_backward_forward_part3.py Switch dnode shutdown to stopTaosdCompletely().
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_backward_forward_part2.py Switch dnode shutdown to stopTaosdCompletely().
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_backward_forward_part1.py Switch dnode shutdown to stopTaosdCompletely().
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_backward_forward.py Switch dnode shutdown to stopTaosdCompletely().
test/cases/18-StreamProcessing/05-Notify/test_stream_notify_state_multi.py New test validating multi-key state notify payloads (arrays + JSON null behavior).
test/cases/13-TimeSeriesExt/04-StateWindow/test_state_window_null_block.py Add multi-key null-block coverage and update extend syntax to clause form.
test/cases/13-TimeSeriesExt/04-StateWindow/test_state_window_extend.py Update tests from legacy state_window(col, n) to state_window(col) extend(n).
test/cases/13-TimeSeriesExt/04-StateWindow/test_state_window.py Add multi-key state-window expression/zeroth/invalid tests and update extend syntax.
test/cases/11-Functions/05-Compare/test_fun_cmp_if.py Adjust expected behavior for STATE_WINDOW(if(...)) scenario.
test/cases/09-DataQuerying/15-Explain/r/test_explain.result Update expected explain strings to “StateWindow on Columns …”.
test/cases/09-DataQuerying/13-CaseWhen/test_query_case_when.py Split state-window CASE expressions into accepted vs error sets and validate errors.
test/cases/09-DataQuerying/09-Having/test_query_having_bugs.py Update percentile/state-window expectations to use a column key (more than 1 window).
test/cases/09-DataQuerying/08-SubQuery/ans/test_scalar_sub_query2.0.csv Update expected errors for unsupported subquery usage inside STATE_WINDOW.
test/cases/09-DataQuerying/08-SubQuery/ans/test_quantified_sub_query4.0.csv Update error messages to match new parse error spans.
test/cases/09-DataQuerying/08-SubQuery/ans/test_in_sub_query2.0.csv Update error messages to match new parse error spans.
test/cases/05-VirtualTables/ans/test_vtable_plan_replace_tbname.ans Update explain outputs and expected syntax errors related to STATE_WINDOW in vtables.
test/cases/05-VirtualTables/ans/test_vtable_plan_eliminate_virtual_scan.ans Update explain output string to “Columns …”.
source/util/src/tjson.c Add tjsonIsArray() helper.
include/util/tjson.h Export tjsonIsArray() declaration.
source/libs/command/src/explain.c Build and truncate multi-key state desc for explain rows.
source/libs/command/inc/commandInt.h Change explain format to “StateWindow on Columns %s” and add reserved-size constant.
source/libs/planner/test/planStateTest.cpp Add plan test coverage for legacy/extended state window syntaxes and multi expr forms.
source/libs/planner/src/planPhysiCreater.c Switch physical creation from single key to key list (pStateKeys).
source/libs/planner/src/planOptimizer.c Ensure vtable optimizations only apply when state window has exactly one column key.
source/libs/planner/src/planLogicCreater.c Clone state expr list (pStateExprs) and adapt rewriting to list-based form.
source/libs/parser/test/parStreamTest.cpp Add parser tests for EXTEND/ZEROTH_STATE keywords, legacy forms, and multi-key triggers.
source/libs/parser/test/parSelectTest.cpp Add parser tests for multi-key state windows, legacy forms, and invalid mixes.
source/libs/parser/src/parTokenizer.c Add keywords: EXTEND, NO_ZEROTH, ZEROTH_STATE.
source/libs/parser/src/parAstCreater.c Add null literal node creator and refactor StateWindow AST to list-based keys/zeroth.
source/libs/parser/inc/sql.y Extend grammar for multi-key state windows plus clause options and NO_ZEROTH lists.
source/libs/parser/inc/parAst.h Update StateWindow AST constructor signature for expr list.
include/libs/nodes/querynodes.h Update SStateWindowNode to use pExprList/pZerothList.
include/libs/nodes/plannodes.h Change logic/physical nodes to store state expr/key lists.
source/libs/nodes/test/nodesCloneTest.cpp Update clone test to assert list cloning for state window.
source/libs/nodes/src/nodesUtilFuncs.c Destroy new list fields (exprs/zeroths/state keys) correctly.
source/libs/nodes/src/nodesTraverseFuncs.c Traverse/rewrite list fields for state window nodes.
source/libs/nodes/src/nodesMsgFuncs.c Encode/decode physical state window keys as node lists.
source/libs/nodes/src/nodesCodeFuncs.c JSON (de)serialization for node lists with V1 compatibility; nodesStringToList supports array/object.
source/libs/nodes/src/nodesCloneFuncs.c Clone logic/AST nodes with list fields for state-window keys.
source/libs/new-stream/src/streamUtil.c Add JSON building for multi-key state notify payloads (arrays).
source/libs/new-stream/inc/streamInt.h Export multi-key notify builder API.
source/libs/new-stream/inc/streamTriggerTask.h Expand trigger task structs to carry multi-key slot IDs, zeroth list, expr lists, and per-group value arrays.
source/libs/executor/test/queryPlanTests.cpp Update executor plan-test helper to create state-key lists.
source/libs/executor/src/timewindowoperator.c Implement multi-key state window execution: null checks, key assignment, comparisons, cleanup/reset.
source/libs/executor/inc/executorInt.h Update executor state-window info struct to store arrays of state cols/keys.
source/dnode/mnode/impl/src/mndStreamUtil.c Update debug logging for state triggers to reflect multi-slot state.
source/common/src/msg/streamMsg.c Extend stream trigger deploy message encoding/decoding to support multiple slot IDs with sentinel v2 format.
source/common/src/msg/streamJson.c Add JSON encoding/decoding for multi-slot state triggers (keep slotId for backward compatibility).
include/common/streamMsg.h Replace single slotId with pSlotIds and define v2 sentinel constant.
docs/zh/14-reference/03-taos-sql/41-stream.md Document multi-key state window trigger syntax and notify payload semantics.
docs/zh/14-reference/03-taos-sql/24-distinguished.md Document multi-key state-window semantics, EXTEND/ZEROTH_STATE clause forms, NO_ZEROTH.
docs/zh/14-reference/03-taos-sql/20-select.md Update SELECT grammar docs for new state window clause syntax.
docs/zh/06-advanced/03-stream.md Update stream advanced docs to describe multi-key state triggers.
docs/zh/05-basic/03-query.md Update basic query docs to describe multi-key state windows and clause options.
docs/en/14-reference/03-taos-sql/41-stream.md English docs for multi-key state triggers and notify payload arrays.
docs/en/14-reference/03-taos-sql/24-distinguished.md English docs for multi-key state windows, EXTEND/ZEROTH_STATE, NO_ZEROTH, NULL handling.
docs/en/14-reference/03-taos-sql/20-select.md English SELECT docs updated for new state-window clause.
docs/en/06-advanced/03-stream.md English advanced stream docs updated for multi-key state triggers.
docs/en/05-basic/03-query.md English basic query docs updated for multi-key state windows and clause options.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread source/libs/parser/inc/sql.y
Comment thread test/new_test_framework/utils/compatibilityUtil.py
Copilot AI review requested due to automatic review settings April 20, 2026 09:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends TDengine’s STATE_WINDOW to support multiple state keys (columns/expressions), updates related planner/executor/stream trigger handling, and adds/updates tests + documentation to cover the new syntax and behavior.

Changes:

  • Add multi-key parsing/planning/execution for STATE_WINDOW, including new clause-style options EXTEND(...) / ZEROTH_STATE(...) (with legacy syntax coverage in tests).
  • Update stream state-window triggers and notify payloads to carry multi-key state transitions (arrays) and adjust compatibility test utilities to stop services more reliably.
  • Refresh expected outputs (EXPLAIN/ans files) and expand CI task coverage with new state-window and notify test cases.

Reviewed changes

Copilot reviewed 68 out of 69 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/new_test_framework/utils/compatibilityUtil.py Adds more robust process detection and a stronger “stop taosd completely” helper used by compatibility tests
test/ci/cases.task Registers new state-window and notify tests in CI task list
test/cases/18-StreamProcessing/23-Compatibility/*.py Updates compatibility tests to use the new stop helper and improves old/new CLI handling
test/cases/18-StreamProcessing/05-Notify/test_stream_notify_state.py Adds regression tests validating state-window notify payloads for single-key and multi-key windows
test/cases/13-TimeSeriesExt/04-StateWindow/test_state_window*.py Updates tests for new EXTEND(...) syntax and adds multi-key/zeroth/invalid cases
source/libs/parser/inc/sql.y + tokenizer/AST Adds EXTEND, ZEROTH_STATE, NO_ZEROTH tokens and multi-key state-window grammar/AST representation
source/libs/planner/src/* + tests Propagates state exprs as lists through logic/physical plan creation and optimizer gates
source/libs/executor/src/timewindowoperator.c Executes state-window aggregation with multiple key columns (null handling + key comparison/assignment)
source/libs/new-stream/src/streamUtil.c + stream msg/json Emits multi-key state notify content (arrays) and updates state trigger slot serialization
source/libs/command/src/explain.c (+ result fixtures) Updates explain text to “StateWindow on Columns …” and prints multiple keys with truncation
docs/* Documents multi-key state windows, clause options, notify payload formats (scalar vs array)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread source/common/src/msg/streamMsg.c
Copilot AI review requested due to automatic review settings April 21, 2026 07:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds multi-column STATE_WINDOW(...) support across parsing → planning → execution, and updates stream state-window notify payloads and tests accordingly.

Changes:

  • Extend SQL grammar/AST/plans to represent state-window keys as lists (multi-key) and introduce keyword options EXTEND(...) / ZEROTH_STATE(...) / NO_ZEROTH.
  • Update planner/executor implementations for multi-key state-window evaluation and EXPLAIN formatting.
  • Add/adjust regression tests, CI task entries, and compatibility test utilities (process shutdown + CLI-based checks).

Reviewed changes

Copilot reviewed 82 out of 95 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/new_test_framework/utils/compatibilityUtil.py Adds safer PID lookup + robust TDengine shutdown helper used by compatibility tests.
test/ci/cases.task Enables additional state-window tests; adds notify state test entry.
test/cases/18-StreamProcessing/23-Compatibility/test_new_stream_compatibility.py Expands base versions and improves old/new CLI usage + shutdown sequencing.
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_rolling_upgrade_all.py Switches to unified shutdown helper.
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_cross_version.py Centralizes shutdown via tdCb and removes duplicated process-kill helpers.
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_backward_forward_part4.py Uses unified shutdown helper.
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_backward_forward_part3.py Uses unified shutdown helper.
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_backward_forward_part2.py Uses unified shutdown helper.
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_backward_forward_part1.py Uses unified shutdown helper.
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_backward_forward.py Uses unified shutdown helper.
test/cases/18-StreamProcessing/05-Notify/test_stream_notify_state.py New regression test for state-window notify payloads (single-key + multi-key).
test/cases/13-TimeSeriesExt/04-StateWindow/test_state_window_extend.py Migrates legacy positional extend syntax to EXTEND(...) clause form.
test/cases/13-TimeSeriesExt/04-StateWindow/test_state_window.py Adds multi-key state-window tests (expr keys, invalid cases, zeroth_state).
test/cases/09-DataQuerying/15-Explain/r/test_explain.result Updates EXPLAIN output text to “Columns” for state window.
test/cases/09-DataQuerying/09-Having/test_query_having_bugs.py Updates state-window invocation consistent with new semantics.
test/cases/09-DataQuerying/08-SubQuery/ans/test_scalar_sub_query2.0.csv Updates expected error outputs for unsupported subquery usage in STATE_WINDOW.
test/cases/09-DataQuerying/08-SubQuery/ans/test_quantified_sub_query4.0.csv Updates expected error text formatting for STATE_WINDOW syntax errors.
test/cases/09-DataQuerying/08-SubQuery/ans/test_in_sub_query2.0.csv Updates expected error text formatting for STATE_WINDOW syntax errors.
test/cases/05-VirtualTables/test_vtable_plan_window_optimize.py Adds state-window plan coverage for vtable/vctable layers.
test/cases/05-VirtualTables/in/test_vtable_select_test_state_mode_2.in Adds multi-key state-window virtual-table queries.
test/cases/05-VirtualTables/in/test_vtable_select_test_state_mode_1.in Adds multi-key state-window virtual-table queries.
test/cases/05-VirtualTables/in/test_vtable_select_test_state_mode_0.in Adds multi-key state-window virtual-table queries.
test/cases/05-VirtualTables/in/test_vtable_plan_test_window_state.in New EXPLAIN coverage for vtable + multi-key state window.
test/cases/05-VirtualTables/in/test_vstable_select_test_state_mode_2.in Adds multi-key state-window vstable queries.
test/cases/05-VirtualTables/in/test_vstable_select_test_state_mode_1.in Adds multi-key state-window vstable queries.
test/cases/05-VirtualTables/in/test_vstable_select_test_state_mode_0.in Adds multi-key state-window vstable queries.
test/cases/05-VirtualTables/in/test_vstable_plan_test_window_state.in Adds EXPLAIN coverage for vstable + multi-key state window.
test/cases/05-VirtualTables/in/test_vctable_select_test_state_mode_2.in Adds multi-key state-window vctable queries.
test/cases/05-VirtualTables/in/test_vctable_select_test_state_mode_1.in Adds multi-key state-window vctable queries.
test/cases/05-VirtualTables/in/test_vctable_select_test_state_mode_0.in Adds multi-key state-window vctable queries.
test/cases/05-VirtualTables/in/test_vctable_select_test_state.in Adds multi-key state-window vctable queries.
test/cases/05-VirtualTables/in/test_vctable_plan_test_window_state.in New EXPLAIN coverage for vctable + multi-key state window.
test/cases/05-VirtualTables/ans/test_vtable_plan_replace_tbname.ans Updates expected EXPLAIN output/error for tbname + state window.
test/cases/05-VirtualTables/ans/test_vtable_plan_eliminate_virtual_scan.ans Updates expected EXPLAIN output text for state window.
source/util/src/tjson.c Adds tjsonIsArray helper wrapper.
include/util/tjson.h Declares tjsonIsArray.
source/libs/planner/test/planStateTest.cpp Adds planner tests for multi-arg STATE_WINDOW.
source/libs/planner/src/planPhysiCreater.c Switches state key handling from single node to list.
source/libs/planner/src/planOptimizer.c Updates vtable/vstable window optimizations for multi-key state windows.
source/libs/planner/src/planLogicCreater.c Stores state-window expressions as a list (pStateExprs).
source/libs/parser/test/parSelectTest.cpp Adds parser tests for new state-window forms and legacy syntax.
source/libs/parser/src/parTokenizer.c Adds keywords: EXTEND, ZEROTH_STATE, NO_ZEROTH.
source/libs/parser/src/parAstCreater.c Adds createNullValueNode; rewires state window node creation to list-based.
source/libs/parser/inc/sql.y Updates grammar to parse multi-key state_window + new option clauses.
source/libs/parser/inc/parAst.h Updates createStateWindowNode signature.
source/libs/nodes/test/nodesCloneTest.cpp Updates clone tests for list-based state-window expressions.
source/libs/nodes/src/nodesUtilFuncs.c Updates destruction paths for list-based state window fields.
source/libs/nodes/src/nodesTraverseFuncs.c Updates traversal/rewriter for list-based state window fields.
source/libs/nodes/src/nodesMsgFuncs.c Serializes/deserializes physical state keys as a list.
source/libs/nodes/src/nodesCodeFuncs.c JSON encode/decode compat for list-based state exprs/keys + nodesStringToList array/object compat.
source/libs/nodes/src/nodesCloneFuncs.c Clones list-based state window fields and logic window state exprs list.
include/libs/nodes/querynodes.h Updates SStateWindowNode fields to pExprList/pZerothList.
include/libs/nodes/plannodes.h Updates plan nodes to hold pStateExprs and pStateKeys lists.
source/libs/new-stream/src/streamUtil.c Builds state notify content as arrays for state keys; adds helpers.
source/libs/new-stream/inc/streamTriggerTask.h Switches trigger task to hold arrays/lists for state slots/exprs/zeroths.
source/libs/new-stream/inc/streamInt.h Renames notify builder API to multi-state version.
source/libs/executor/test/queryPlanTests.cpp Updates executor plan test generator for list-based state keys.
source/libs/executor/src/timewindowoperator.c Implements multi-key comparisons + storage for state window execution.
source/libs/executor/inc/executorInt.h Updates operator info to hold arrays of state cols/keys.
source/libs/command/src/explain.c Builds comma-separated state-key descriptions for EXPLAIN output.
source/libs/command/inc/commandInt.h Updates EXPLAIN format string and reserved size constant.
source/dnode/mnode/impl/src/mndStreamUtil.c Updates log output for multi-slot state triggers.
source/common/src/msg/streamMsg.c Encodes/decodes state trigger slot IDs as list with v2 sentinel.
source/common/src/msg/streamJson.c JSON enc/dec for state trigger slotIds array with compat for old slotId.
include/common/streamMsg.h Replaces single slotId with slotId array + defines v2 sentinel constant.
docs/zh/14-reference/03-taos-sql/41-stream.md Documents new state_window syntax and notify semantics.
docs/zh/14-reference/03-taos-sql/24-distinguished.md Updates state window docs for multi-key + new clauses.
docs/zh/14-reference/03-taos-sql/20-select.md Updates SELECT window clause docs for new syntax/options.
docs/zh/06-advanced/03-stream.md Updates stream docs for new state_window syntax and semantics.
docs/zh/05-basic/03-query.md Updates basic query docs for multi-key state windows.
docs/en/14-reference/03-taos-sql/41-stream.md Documents new state_window syntax and notify semantics.
docs/en/14-reference/03-taos-sql/24-distinguished.md Updates state window docs for multi-key + new clauses.
docs/en/14-reference/03-taos-sql/20-select.md Updates SELECT window clause docs for new syntax/options.
docs/en/06-advanced/03-stream.md Updates stream docs for new state_window syntax and semantics.
docs/en/05-basic/03-query.md Updates basic query docs for multi-key state windows.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread source/libs/parser/inc/sql.y
Comment thread docs/zh/14-reference/03-taos-sql/41-stream.md Outdated
Comment thread docs/en/14-reference/03-taos-sql/41-stream.md Outdated
Copilot AI review requested due to automatic review settings April 23, 2026 08:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends TDengine’s STATE_WINDOW feature to support multiple state keys (multi columns/expressions) and updates related planning, stream trigger/notify payloads, EXPLAIN output, tests, and documentation to match the new behavior and syntax.

Changes:

  • Add multi-key parsing/AST/plan node support for STATE_WINDOW(state_expr [, ...]) plus keyword options EXTEND(...) and ZEROTH_STATE(...) (incl. NO_ZEROTH).
  • Update planner/executor/serialization paths to carry lists of state keys (and related fields) instead of single key.
  • Expand/adjust test coverage, CI case lists, EXPLAIN golden outputs, and user documentation to reflect multi-key behavior and new option syntax.

Reviewed changes

Copilot reviewed 83 out of 96 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/new_test_framework/utils/compatibilityUtil.py More robust process discovery + full stop routine for compatibility tests.
test/ci/cases.task Adds new StateWindow and stream notify test entries to CI task list.
test/cases/18-StreamProcessing/23-Compatibility/test_new_stream_compatibility.py Extends compatibility matrix and improves CLI invocation for old/new versions.
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_rolling_upgrade_all.py Uses new “stop completely” helper instead of legacy kill routine.
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_cross_version.py Switches cleanup to shared stop helper and removes duplicated process logic.
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_backward_forward_part4.py Replaces killAllDnodes with stopTaosdCompletely in upgrade flow.
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_backward_forward_part3.py Same stop helper substitution.
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_backward_forward_part2.py Same stop helper substitution.
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_backward_forward_part1.py Same stop helper substitution.
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_backward_forward.py Same stop helper substitution.
test/cases/13-TimeSeriesExt/04-StateWindow/test_state_window_extend.py Updates legacy state_window(col, extend) syntax to EXTEND(...) clause form.
test/cases/13-TimeSeriesExt/04-StateWindow/test_state_window.py Adds multi-key state window tests + updates extend syntax usage.
test/cases/09-DataQuerying/15-Explain/r/test_explain.result Updates EXPLAIN expected text for “Columns” (plural) formatting.
test/cases/09-DataQuerying/13-CaseWhen/test_query_case_when.py Refactors state window CASE-WHEN test generation; separates valid vs error cases.
test/cases/09-DataQuerying/09-Having/test_query_having_bugs.py Adjusts regression to use STATE_WINDOW(c1) and updates expected rows.
test/cases/09-DataQuerying/08-SubQuery/ans/test_scalar_sub_query2.0.csv Updates expected errors for invalid subquery usage inside STATE_WINDOW.
test/cases/09-DataQuerying/08-SubQuery/ans/test_quantified_sub_query4.0.csv Updates expected error spans for quantified subquery expressions in STATE_WINDOW.
test/cases/09-DataQuerying/08-SubQuery/ans/test_in_sub_query2.0.csv Updates expected error spans for IN-subquery expressions in STATE_WINDOW.
test/cases/05-VirtualTables/test_vtable_plan_window_optimize.py Adds plan validation runs for vtable/vctable state-window cases.
test/cases/05-VirtualTables/in/test_vtable_select_test_state_mode_2.in Adds multi-key STATE_WINDOW queries for virtual normal table.
test/cases/05-VirtualTables/in/test_vtable_select_test_state_mode_1.in Adds multi-key STATE_WINDOW queries for virtual normal table.
test/cases/05-VirtualTables/in/test_vtable_select_test_state_mode_0.in Adds multi-key STATE_WINDOW queries for virtual normal table.
test/cases/05-VirtualTables/in/test_vtable_plan_test_window_state.in New vtable state-window EXPLAIN coverage including multi-key variants.
test/cases/05-VirtualTables/in/test_vstable_select_test_state_mode_2.in Adds multi-key STATE_WINDOW queries for virtual stable.
test/cases/05-VirtualTables/in/test_vstable_select_test_state_mode_1.in Adds multi-key STATE_WINDOW queries for virtual stable.
test/cases/05-VirtualTables/in/test_vstable_select_test_state_mode_0.in Adds multi-key STATE_WINDOW queries for virtual stable.
test/cases/05-VirtualTables/in/test_vstable_plan_test_window_state.in Adds EXPLAIN coverage for multi-key state windows in vstable plans.
test/cases/05-VirtualTables/in/test_vctable_select_test_state_mode_2.in Adds multi-key STATE_WINDOW queries for virtual child table.
test/cases/05-VirtualTables/in/test_vctable_select_test_state_mode_1.in Adds multi-key STATE_WINDOW queries for virtual child table.
test/cases/05-VirtualTables/in/test_vctable_select_test_state_mode_0.in Adds multi-key STATE_WINDOW queries for virtual child table.
test/cases/05-VirtualTables/in/test_vctable_select_test_state.in Adds multi-key STATE_WINDOW queries to existing vctable state test.
test/cases/05-VirtualTables/in/test_vctable_plan_test_window_state.in New vctable state-window EXPLAIN coverage including multi-key variants.
test/cases/05-VirtualTables/ans/test_vtable_plan_replace_tbname.ans Updates expected EXPLAIN output/error behavior for tbname + state window.
test/cases/05-VirtualTables/ans/test_vtable_plan_eliminate_virtual_scan.ans Updates expected EXPLAIN output wording (“Columns”).
source/util/src/tjson.c Adds tjsonIsArray() wrapper for JSON compatibility handling.
source/libs/planner/test/planStateTest.cpp Adds planner tests for multi-key and legacy-arg state windows.
source/libs/planner/src/planPhysiCreater.c Carries state keys as a list into physical plan node.
source/libs/planner/src/planOptimizer.c Extends vtable/vstable window optimization to handle multi-key state windows.
source/libs/planner/src/planLogicCreater.c Logic plan now stores state exprs as a list; extend option read from node field.
source/libs/parser/test/parSelectTest.cpp Adds parser coverage for multi-key + options + legacy-arg syntax.
source/libs/parser/src/parTokenizer.c Adds keywords: EXTEND, ZEROTH_STATE, NO_ZEROTH.
source/libs/parser/src/parAstCreater.c Adds NULL literal node creation + parses new state-window options into node fields.
source/libs/parser/inc/sql.y Grammar updated for multi-key state windows and keyword options.
source/libs/parser/inc/parAst.h Updates createStateWindowNode signature to accept expr list.
source/libs/nodes/test/nodesCloneTest.cpp Updates clone test for state window node list fields.
source/libs/nodes/src/nodesUtilFuncs.c Ensures state-window node destruction frees lists (exprs/zeroths/keys).
source/libs/nodes/src/nodesTraverseFuncs.c Traversal/rewriter now walks lists for state exprs and zeroth list.
source/libs/nodes/src/nodesMsgFuncs.c Physical plan message encode/decode updated for list of state keys.
source/libs/nodes/src/nodesCodeFuncs.c JSON serialization adds list fields and backward-compatible decoding.
source/libs/nodes/src/nodesCloneFuncs.c Clone logic updated for list-based state-window fields.
source/libs/new-stream/src/streamUtil.c Stream notify JSON builder updated for multi-key state transitions (arrays).
source/libs/new-stream/inc/streamTriggerTask.h Stream trigger task structs updated to track multi-key state values.
source/libs/new-stream/inc/streamInt.h Exposes new multi-state notify builder signature.
source/libs/executor/test/queryPlanTests.cpp Updates executor plan test node generator for list of state keys.
source/libs/executor/inc/executorInt.h Executor state-window operator tracks multiple state columns/keys + partial-null deferral fields.
source/libs/command/src/explain.c EXPLAIN now prints comma-separated state keys with truncation.
source/libs/command/inc/commandInt.h Updates EXPLAIN format string to “Columns”.
source/dnode/mnode/impl/src/mndStreamUtil.c Stream trigger logging updated for multi-slot state triggers.
source/common/src/msg/streamMsg.c Deploy msg encoding/decoding updated for multi-slot state triggers with sentinel.
source/common/src/msg/streamJson.c JSON encoding/decoding updated from slotId to slotIds (with compat).
include/util/tjson.h Declares new tjsonIsArray() helper.
include/libs/nodes/querynodes.h State window AST node now stores expr/zeroth as lists.
include/libs/nodes/plannodes.h Plan nodes updated for pStateExprs and pStateKeys lists.
include/common/streamMsg.h State trigger struct updated to slotIds array and adds v2 sentinel constant.
docs/zh/14-reference/03-taos-sql/41-stream.md Updates stream SQL syntax + notify payload semantics for multi-key state windows.
docs/zh/14-reference/03-taos-sql/24-distinguished.md Updates state window reference syntax and examples to multi-key + keyword options.
docs/zh/14-reference/03-taos-sql/20-select.md Updates SELECT window clause docs for new state window syntax/semantics.
docs/zh/06-advanced/03-stream.md Updates advanced stream docs for multi-key state window triggers.
docs/zh/05-basic/03-query.md Updates basic query docs for multi-key state window overview and syntax.
docs/en/14-reference/03-taos-sql/41-stream.md English stream docs updated for multi-key syntax + payload arrays.
docs/en/14-reference/03-taos-sql/24-distinguished.md English state window reference updated for multi-key semantics and examples.
docs/en/14-reference/03-taos-sql/20-select.md English SELECT docs updated for new state window syntax/semantics.
docs/en/06-advanced/03-stream.md English advanced stream docs updated for multi-key state windows.
docs/en/05-basic/03-query.md English basic query docs updated for multi-key state window overview and syntax.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread source/libs/parser/inc/sql.y
Copilot AI review requested due to automatic review settings April 24, 2026 01:57
Tony2h and others added 26 commits April 26, 2026 23:08
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
…LL rows

Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Copilot AI review requested due to automatic review settings April 26, 2026 15:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends TDengine’s STATE_WINDOW to support multiple state keys, introduces keyword-style options (EXTEND(...), ZEROTH_STATE(...) with NO_ZEROTH), updates planner/executor/stream-trigger plumbing to carry multi-key state metadata, and refreshes docs + tests accordingly.

Changes:

  • Parser/AST/plan node updates to represent state-window keys as lists (logic + physical plan), with JSON/msg backward-compat where needed.
  • Stream trigger notify payloads updated to emit state values as arrays (length = key count) and state-window trigger deploy messages updated for multi-slot IDs.
  • Broad test and documentation updates covering new syntax and multi-key behavior (including NULL/partial-NULL handling).

Reviewed changes

Copilot reviewed 89 out of 102 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/new_test_framework/utils/compatibilityUtil.py Adds robust process detection and a stronger “stop TDengine completely” helper used by compatibility tests.
test/ci/cases.task Adds new pytest cases for state-window regression coverage and one stream notify test entry.
test/cases/18-StreamProcessing/23-Compatibility/test_new_stream_compatibility.py Expands baseline versions and uses explicit old/new taos CLI invocation with improved stream checks.
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_rolling_upgrade_all.py Switches from killAllDnodes() to the new stop helper.
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_cross_version.py Uses shared stop helper; removes duplicated process-kill logic.
test/cases/18-StreamProcessing/23-Compatibility/test_compatibility_backward_forward*.py Uses shared stop helper between version cycles.
test/cases/13-TimeSeriesExt/04-StateWindow/test_state_window_extend.py Updates to keyword extend() syntax and related invalid-input assertions.
test/cases/13-TimeSeriesExt/04-StateWindow/test_state_window.py Adds multi-key state-window functional + invalid-input tests and updates to new extend() syntax.
test/cases/09-DataQuerying/15-Explain/r/test_explain.result Updates explain output wording from “Column” to “Columns”.
test/cases/09-DataQuerying/09-Having/test_query_having_bugs.py Adjusts state-window tests to use column keys and updated expected row counts.
test/cases/09-DataQuerying/08-SubQuery/ans/*.csv Updates expected errors for subquery usage inside STATE_WINDOW(...).
test/cases/05-VirtualTables/test_vtable_query_*.py Adds config overrides (minReservedMemorySize) for vtable test stability.
test/cases/05-VirtualTables/test_vtable_plan_window_optimize.py Expands plan test coverage to vtable/vctable state-window plan cases.
test/cases/05-VirtualTables/in/.in / ans/.ans Adds new multi-key state-window queries and explain-plan fixtures.
source/util/src/tjson.c / include/util/tjson.h Adds tjsonIsArray() helper for JSON decoding compatibility paths.
source/libs/planner/test/planStateTest.cpp Adds planner test coverage for multi-arg STATE_WINDOW(...).
source/libs/planner/src/planPhysiCreater.c Uses list-based precalc rewrite + slot assignment for multiple state keys.
source/libs/planner/src/planOptimizer.c Updates vtable/vstable window optimization logic for multi-key state expr lists.
source/libs/planner/src/planLogicCreater.c Logical plan now stores state-window expressions as a list.
source/libs/parser/test/parSelectTest.cpp Adds parser/semantic coverage for new syntax and multi-key keys/options.
source/libs/parser/src/parTokenizer.c Registers EXTEND, NO_ZEROTH, ZEROTH_STATE keywords.
source/libs/parser/src/parAstCreater.c / source/libs/parser/inc/parAst.h State-window AST node now holds key list + zeroth list; adds createNullValueNode().
source/libs/parser/inc/sql.y Grammar updated for multi-key keys + keyword options; adds NO_ZEROTH handling.
source/libs/nodes/* Updates clone/destroy/traverse/JSON/TLV for list-based state-window fields with backward-compat decoding.
source/libs/new-stream/src/streamUtil.c / source/libs/new-stream/inc/streamInt.h Reworks state notify JSON building to support multi-key arrays.
source/libs/new-stream/inc/streamTriggerTask.h Expands trigger task state window structs for multi-key values + partial-NULL deferral tracking.
source/libs/executor/inc/executorInt.h Expands executor state-window operator bookkeeping for multi-key + deferred partial-NULL rows.
source/libs/command/src/explain.c / source/libs/command/inc/commandInt.h Explain output now prints multiple state key names with truncation.
source/dnode/mnode/impl/src/mndStreamUtil.c Logging updated for multi-slot state trigger options.
source/common/src/msg/streamMsg.c / streamJson.c / include/common/streamMsg.h Deploy msg + JSON updated for multi-slot/multi-key state triggers with backward-compat decoding.
docs/** Updates SQL and stream docs (zh/en) to reflect multi-key state-window syntax + notification payload format.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread source/libs/parser/inc/sql.y
Comment thread source/libs/parser/src/parAstCreater.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants