feat(sql): recognize dateadd predicates in time intrinsic filters#6666
feat(sql): recognize dateadd predicates in time intrinsic filters#6666bluestreak01 merged 3 commits intomasterfrom
Conversation
WalkthroughImplements support for recognizing dateadd function calls on designated timestamp columns in WHERE clause predicates. Adds AST rewrite logic to transform dateadd-wrapped timestamp expressions into forms that existing time intrinsic analysis can recognize, enabling query optimization for filters like Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ast-grep (0.40.5)core/src/main/java/io/questdb/griffin/SqlCodeGenerator.javacore/src/test/java/io/questdb/test/griffin/ExplainPlanTest.javacore/src/test/java/io/questdb/test/griffin/WhereClauseParserTest.javaThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
[PR Coverage check]😍 pass : 120 / 127 (94.49%) file detail
|
|
@bluestreak01 thanks for the review! |
Closes #6506
dateadd()calls are now recognized in time intrinsics.How It Works
When you write:
The optimizer now transforms it to:
Which evaluates to:
This allows the existing interval-based partition pruning to work, significantly improving query performance by skipping irrelevant partitions.
Changes Made
Added AST rewriting step to
WhereClauseParserto transformdateadd(period, stride, designated_ts) OP valueintodesignated_ts OP dateadd(period, -stride, value):rewriteDateaddTimestamp()- Entry point that recursively traversesAND-connected predicates=,!=,<,<=,>,>=)BETWEENexpressions