-
Notifications
You must be signed in to change notification settings - Fork 5k
fix(state window): status is null if window data start with null #33679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Summary of ChangesHello @Tony2h, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves an issue where state window aggregations produced incorrect Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this 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 fixes an issue where the state of a state_window could be incorrectly determined as NULL if the window's data starts with a NULL value. The fix introduces a new hasWindow flag to differentiate window operations from group by operations. The core logic in groupConstValueFunction is updated to re-evaluate the state for a window if the previously determined state was NULL.
The changes are logical and the new test case validates the fix for the described scenario. However, I've found a potential correctness issue in the new logic for finding a non-null state value within a data chunk, which I've detailed in a specific comment. The current implementation only checks the first and last rows, which could fail for certain data patterns. My suggestion is to scan for the first available non-null value to make the logic more robust.
Additionally, the pull request includes a fix for a memory leak in tDeserializeSCMCreateStreamReqImpl, which is a good improvement.
| if (isWindow) { | ||
| // for 'window', non-null value can be from either start or end row | ||
| int32_t startIndex = pInput->startRowIndex; | ||
| int32_t endIndex = pInput->startRowIndex + pInput->numOfRows - 1; | ||
| if (!colDataIsNull_s(pInputCol, startIndex)) { | ||
| valueRowIndex = startIndex; | ||
| } else if (!colDataIsNull_s(pInputCol, endIndex)) { | ||
| valueRowIndex = endIndex; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current logic to find a non-null value for a window only checks the start and end rows of the data chunk. This is a performance heuristic but it's not correct in all cases. For a state_window, the state is constant across the window (ignoring NULLs). If a block of data for a window has non-null values only in the middle, and NULL at both start and end (e.g., [NULL, 'a', 'a', NULL]), this logic will incorrectly determine the state is NULL.
To ensure correctness, the code should scan the chunk to find the first non-null value. This will be more robust.
if (isWindow) {
// for 'window', find first non-null value in the current data chunk
for (int32_t i = 0; i < pInput->numOfRows; ++i) {
int32_t currentRow = pInput->startRowIndex + i;
if (!colDataIsNull_s(pInputCol, currentRow)) {
valueRowIndex = currentRow;
break;
}
}
}9790f13 to
9330ddc
Compare
Description
Please briefly describe the code changes in this pull request.
Jira: https://jira.taosdata.com:18080/browse/TD-
Checklist
Please check the items in the checklist if applicable.