-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
bugSomething isn't workingSomething isn't workingtriageNewly created issue that needs attention.Newly created issue that needs attention.
Description
Bug description
Summary
The DuckDB parser bundled in Velox (v0.8.1) always defaults the window frame end bound to CURRENT ROW, regardless of whether ORDER BY is present. The SQL standard specifies different defaults:
- With ORDER BY:
RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW - Without ORDER BY:
RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
Reproduction
auto windowExpr = parse::DuckSqlExpressionsParser().parseWindowExpr(
"rank() OVER (PARTITION BY a)");
// windowExpr.frame.endType is kCurrentRow
// Expected: kUnboundedFollowing (per SQL standard, no ORDER BY)The existing DuckDB parser test in velox/duckdb/conversion/tests/DuckParserTest.cpp confirms this behavior:
EXPECT_EQ(
"row_number() AS a OVER ( RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)",
parseWindow("row_number() over () as a"));Impact
Any code using DuckSqlExpressionsParser::parseWindowExpr() to parse window expressions without ORDER BY gets the wrong default frame. The Axiom query optimizer works around this in its test PlanMatcher, but the fix belongs in the parser.
Suggested Fix
Upgrade to a newer DuckDB version.
CC: @majetideepak @aditi-pandit @kgpai @amitkdutta @natashasehgal @czentgr
System information
n/a
Relevant logs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingtriageNewly created issue that needs attention.Newly created issue that needs attention.