fix: fix crash in scalar caused by window function without from#35043
Merged
guanshengliang merged 1 commit intomainfrom Apr 2, 2026
Merged
fix: fix crash in scalar caused by window function without from#35043guanshengliang merged 1 commit intomainfrom
guanshengliang merged 1 commit intomainfrom
Conversation
…s in query without FROM Defect: #6935331548 Root cause: Window pseudo-column functions (_wend, _wstart, _wduration, _irowts, _isfilled) were not rejected at parse time in no-FROM (dual) queries. They reached the scalar execution layer where winEndTsFunction tried to read row data from empty/uninitialized input via colDataGetData(pInput->columnData, 4), causing a SIGSEGV at source/libs/scalar/src/sclfunc.c:4748. Fix in parser (parTranslater.c): - Add validateDualQueryFunc called from translateFunction that rejects at parse time all functions unsupported without a table: UDFs, window pseudo-column funcs, and agg funcs that have no scalar exec path - Client pseudo-column funcs (_qstart, _qend, _qduration) are allowed as they are rewritten to constants by rewriteClientPseudoColumnFunc - Add early return in rewriteCountStar and rewriteCountNotNullValue when pCxt->dual is set; this also fixes count(1)/count(*) without FROM incorrectly returning TABLE_NOT_EXIST (found during investigation) Fix in scalar (scalar.c): - Correct the boolean condition in sclRewriteFunction from (!scalar && !dual) || UDF to !dual && (!scalar || UDF) so that in dual mode all functions are routed to scalar execution (no premature DEAL_RES_CONTINUE skip) while in normal mode non-scalar functions and UDFs are still skipped for executor handling Test: add test/cases/11-Functions/09-NoFrom/test_fun_no_from_all.py covering 120+ positive cases and 11 negative cases; register in cases.task
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a crash triggered by using window pseudo-column functions (e.g., _wend, _wstart) in SELECT ... queries without a FROM clause by rejecting unsupported functions during parsing and adjusting scalar constant-folding behavior in dual-query mode.
Changes:
- Add parser-side validation for dual (no-FROM) queries to reject UDFs, window pseudo-column functions, and non-scalar functions without a scalar execution path.
- Fix scalar rewrite routing so dual-mode functions are evaluated in the scalar layer rather than being prematurely skipped.
- Add a comprehensive no-FROM function test suite and register it in CI.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
source/libs/parser/src/parTranslater.c |
Adds dual-query function validation and adjusts count(*) / count(1) rewrites for no-FROM queries. |
source/libs/scalar/src/scalar.c |
Fixes conditional logic so dual-mode function rewriting/execution is routed correctly. |
test/cases/11-Functions/09-NoFrom/test_fun_no_from_all.py |
New test covering many supported/unsupported function calls in no-FROM queries. |
test/ci/cases.task |
Registers the new no-FROM test in CI task list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
guanshengliang
approved these changes
Apr 2, 2026
jiajingbin
pushed a commit
that referenced
this pull request
Apr 8, 2026
…s in query without FROM (#35043)
wangmm0220
pushed a commit
that referenced
this pull request
Apr 14, 2026
…s in query without FROM (#35043)
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.
…s in query without FROM
Defect: #6935331548
Root cause: Window pseudo-column functions (_wend, _wstart, _wduration, _irowts, _isfilled) were not rejected at parse time in no-FROM (dual) queries. They reached the scalar execution layer where winEndTsFunction tried to read row data from empty/uninitialized input via colDataGetData(pInput->columnData, 4), causing a SIGSEGV at source/libs/scalar/src/sclfunc.c:4748.
Fix in parser (parTranslater.c):
Fix in scalar (scalar.c):
Test: add test/cases/11-Functions/09-NoFrom/test_fun_no_from_all.py covering 120+ positive cases and 11 negative cases; register in cases.task
Description
Issue(s)
Checklist
Please check the items in the checklist if applicable.