Skip to content

fix: fix crash in scalar caused by window function without from#35043

Merged
guanshengliang merged 1 commit intomainfrom
fix/6935331548
Apr 2, 2026
Merged

fix: fix crash in scalar caused by window function without from#35043
guanshengliang merged 1 commit intomainfrom
fix/6935331548

Conversation

@dapan1121
Copy link
Copy Markdown
Contributor

…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

Description

Issue(s)

  • Close/close/Fix/fix/Resolve/resolve: Issue Link

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?

…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
Copilot AI review requested due to automatic review settings April 2, 2026 03:16
@dapan1121 dapan1121 requested a review from a team as a code owner April 2, 2026 03:16
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

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 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.

Comment thread test/cases/11-Functions/09-NoFrom/test_fun_no_from_all.py
Comment thread test/cases/11-Functions/09-NoFrom/test_fun_no_from_all.py
@guanshengliang guanshengliang merged commit 21a5fe4 into main Apr 2, 2026
16 of 17 checks passed
jiajingbin pushed a commit that referenced this pull request Apr 8, 2026
wangmm0220 pushed a commit that referenced this pull request Apr 14, 2026
@dapan1121 dapan1121 deleted the fix/6935331548 branch April 30, 2026 01:01
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