Skip to content

fix(sql): fix stale interval evaluation for tick expressions with date variables in filter functions#6798

Merged
bluestreak01 merged 2 commits intomasterfrom
vi_fix_dyn_now
Feb 20, 2026
Merged

fix(sql): fix stale interval evaluation for tick expressions with date variables in filter functions#6798
bluestreak01 merged 2 commits intomasterfrom
vi_fix_dyn_now

Conversation

@bluestreak01
Copy link
Copy Markdown
Member

@bluestreak01 bluestreak01 commented Feb 20, 2026

Fixes #6797

Summary

  • Tick expressions containing date variables ($now, $today, etc.) used as filter
    predicates — e.g., WHERE now() IN '$now-100s..$now' — resolved $now once at
    compile time and cached the resulting interval as static timestamps. On repeated
    execution of a cached SQL statement, the interval never updated, causing the filter
    to return 0 rows once now() moved past the originally computed range.
  • The interval model path (used for tables with a designated timestamp) was already
    fixed in fix(sql): compile tick expressions with date variables into IR for zero-parse evaluation when executing caches SQL statements #6780 to compile such expressions into IR via CompiledTickExpression.
    The filter function path in InTimestampTimestampFunctionFactory was not updated
    and still used the static EqTimestampStrConstantFunction.
  • The fix detects date variables in constant tick expression strings and routes them
    through CompiledTickExpression, which re-evaluates the interval from IR on each
    execution via init().

Test plan

  • New test testNowInTickExprWithDateVariableReevaluatesOnCachedExecution compiles
    WHERE now() IN '$now-100s..$now' once, executes the factory at T1 (expects 1 row),
    advances now() by 200s, and re-executes (expects 1 row again)
  • All existing InTimestampTimestampTest tests pass (no regressions in constant and
    bind-variable interval paths)

🤖 Generated with Claude Code

@bluestreak01 bluestreak01 added Bug Incorrect or unexpected behavior SQL Issues or changes relating to SQL execution labels Feb 20, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 20, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch vi_fix_dyn_now

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@nwoolmer nwoolmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@glasstiger
Copy link
Copy Markdown
Contributor

[PR Coverage check]

😍 pass : 22 / 28 (78.57%)

file detail

path covered line new line coverage
🔵 io/questdb/griffin/engine/functions/bool/InTimestampTimestampFunctionFactory.java 22 28 78.57%

@bluestreak01 bluestreak01 merged commit 2f95772 into master Feb 20, 2026
44 checks passed
@bluestreak01 bluestreak01 deleted the vi_fix_dyn_now branch February 20, 2026 20:06
maciulis pushed a commit to maciulis/questdb that referenced this pull request Feb 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Incorrect or unexpected behavior SQL Issues or changes relating to SQL execution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

strange now() behaviour with TICK filter

3 participants