feat(stream): support nested event window sub-events#35149
feat(stream): support nested event window sub-events#35149JinqingKuang wants to merge 2 commits intomainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements multi-level nested sub-event support for EVENT_WINDOW in stream processing. It introduces the _event_condition_path placeholder to identify matched nodes within a hierarchical start-condition tree and updates the notification payload to include conditionPath. The implementation includes changes to the parser, stream trigger task logic, and documentation. Feedback was provided regarding safer path length calculations and ensuring null-safety when evaluating event conditions.
| for (int32_t i = 0; i < nrows; ++i) { | ||
| if (pResData[i] == 0 && pTmpData[i]) { | ||
| pResData[i] = nodeId + 1; | ||
| } | ||
| } |
There was a problem hiding this comment.
The loop for updating pResData does not check the null bitmap of tmpCol. If a condition evaluates to NULL, pTmpData[i] might contain an undefined value or 0. It is safer to explicitly check the null bitmap to ensure only non-null TRUE values are recorded as matches.
for (int32_t i = 0; i < nrows; ++i) {
if (pResData[i] == 0 && !colDataIsNull(&tmpCol, i) && pTmpData[i]) {
pResData[i] = nodeId + 1;
}
}There was a problem hiding this comment.
Pull request overview
This PR extends TDengine stream EVENT_WINDOW support to allow recursively nested START WITH groups, propagates a stable runtime “conditionPath” for matched nodes, and exposes that path via the new _event_condition_path placeholder and updated notification payload fields.
Changes:
- Parser: add recursive
START WITHgrammar (start_event_item) and validation for_event_condition_pathusage. - Runtime: build/start-condition metadata (node ids + stable paths), evaluate nested start trees, and propagate
conditionPaththrough trigger calc params and notifications. - Function/Scalar plumbing: register
_event_condition_pathas a pseudo/placeholder function and populate its value at execution time; add tests and docs.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/cases/18-StreamProcessing/03-TriggerMode/test_event_new.py | Adds a system test verifying nested start groups produce expected _event_condition_path values. |
| source/libs/scalar/src/scalar.c | Populates _event_condition_path placeholder results via new varstring setters. |
| source/libs/parser/test/parStreamTest.cpp | Adds parser tests for nested start condition AST shape and placeholder legality. |
| source/libs/parser/src/parTranslater.c | Tracks placeholder bitmap and enforces _event_condition_path validity for event windows with sub-events. |
| source/libs/parser/src/parTokenizer.c | Adds keyword mapping for _EVENT_CONDITION_PATH. |
| source/libs/parser/inc/sql.y | Introduces recursive start_event_item grammar and _event_condition_path pseudo column. |
| source/libs/new-stream/src/streamUtil.c | Updates event notification payload to include conditionPath + conditionIndex and removes windowIndex. |
| source/libs/new-stream/src/streamTriggerTask.c | Implements nested start-condition evaluation, path switching, and conditionPath propagation into calc params/notifications. |
| source/libs/new-stream/inc/streamTriggerTask.h | Extends window structs with eventNodeId and adds start-condition meta structures. |
| source/libs/new-stream/inc/streamInt.h | Updates streamBuildEventNotifyContent signature to accept conditionPath. |
| source/libs/function/src/functionMgt.c | Exposes conditionPath as a stream pseudo value and wires placeholder parameter updates. |
| source/libs/function/src/builtins.c | Registers _event_condition_path builtin and its return type handling. |
| source/common/src/msg/streamMsg.c | Serializes/deserializes conditionPath in SSTriggerCalcParam and frees it in destructor. |
| include/libs/function/functionMgt.h | Adds FUNCTION_TYPE_EVENT_CONDITION_PATH. |
| include/common/streamMsg.h | Adds placeholder bit + conditionPath field to trigger calc param struct. |
| docs/zh/06-advanced/03-stream.md | Documents nested start_event_item and _event_condition_path (ZH advanced). |
| docs/zh/14-reference/03-taos-sql/41-stream.md | Updates syntax/semantics and notification JSON fields (ZH reference). |
| docs/en/06-advanced/03-stream.md | Documents nested start_event_item and _event_condition_path (EN advanced). |
| docs/en/14-reference/03-taos-sql/41-stream.md | Updates syntax/semantics and notification JSON fields (EN reference). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| _exit: | ||
| if (code != TSDB_CODE_SUCCESS) { | ||
| taosMemoryFreeClear(pIds); | ||
| } | ||
| return code; |
There was a problem hiding this comment.
stTriggerTaskGetEventPathNodeIds defines a _exit: label that is never jumped to. With common -Wall/-Werror settings this triggers an -Wunused-label build failure. Remove the label (and the dead cleanup block), or refactor the early returns to goto _exit so the label is actually used.
| _exit: | |
| if (code != TSDB_CODE_SUCCESS) { | |
| taosMemoryFreeClear(pIds); | |
| } | |
| return code; |
039f707 to
cde25f3
Compare
Apply -Wa,--noexecstack to fast-lzma2 in both the external Makefile patch and the Conan build path. Co-authored-by: OpenAI Codex (GPT-5) <noreply@openai.com>
Add recursive EVENT_WINDOW START WITH parsing, runtime conditionPath propagation, and _event_condition_path placeholder support. Co-authored-by: OpenAI Codex GPT-5 <noreply@openai.com>
cde25f3 to
4554448
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -59,7 +60,7 @@ def build(self): | |||
|
|
|||
| # Execute make compilation | |||
| self.run( | |||
| f'make CFLAGS="{cflags}" CC={self.settings.get_safe("compiler", default="gcc")} libfast-lzma2', | |||
| f'make CFLAGS="{cflags}" ASFLAGS="{asflags}" CC={self.settings.get_safe("compiler", default="gcc")} libfast-lzma2', | |||
| cwd=source_folder, | |||
| ) | |||
There was a problem hiding this comment.
ASFLAGS is set to -Wa,--noexecstack unconditionally. That flag is ELF/GNU-as specific and can fail on toolchains where the assembler doesn’t recognize --noexecstack (e.g., macOS/clang-as, some cross toolchains). Consider gating this flag by platform/toolchain (e.g., only Linux/FreeBSD with GNU assembler), or probing support before adding it, to avoid breaking non-Linux builds.
| RM:=rm -rf | ||
|
|
||
| ASFLAGS := | ||
| ASFLAGS := -Wa,--noexecstack | ||
|
|
||
| SONAME:=libfast-lzma2.so.1 |
There was a problem hiding this comment.
ASFLAGS := -Wa,--noexecstack is applied globally. --noexecstack is not universally supported by all assemblers/platforms; applying it unconditionally can break builds on non-ELF targets. Consider conditioning this flag on platforms where it’s supported (e.g., Linux/FreeBSD + GNU as), or appending it only when the assembler is known to accept it.
| SNodeList *pStartCondCols; | ||
| SNodeList *pEndCondCols; | ||
| SArray *pStartCondMeta; // SArray<SSTriggerEventNodeMeta> | ||
| bool startCondHasSubEvents; |
There was a problem hiding this comment.
startCondHasSubEvents is set via stTriggerTaskHasNestedEventStartCond(...), which only returns true for nested start-condition trees (i.e., a list containing another list), not for the existing single-level sub-event form (cond1, cond2, ...). Renaming this field to something like startCondHasNestedSubEvents (or similar) would better reflect its actual meaning and reduce the risk of misuse in future changes.
| bool startCondHasSubEvents; | |
| bool startCondHasNestedSubEvents; |
Description
Add recursive EVENT_WINDOW START WITH parsing, runtime conditionPath propagation, and _event_condition_path placeholder support.
Issue(s)
Checklist
Please check the items in the checklist if applicable.