feat(sql): extend TICK date variable arithmetic with additional time units#6711
feat(sql): extend TICK date variable arithmetic with additional time units#6711bluestreak01 merged 12 commits intomasterfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
WalkthroughDate arithmetic and interval parsing were expanded: DateExpressionEvaluator now accepts many time units (including business days) with stricter parsing and errors; IntervalUtils delegates formatting to TimestampDriver, supports bare Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested labels
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
…e structure - Add new time units for date arithmetic: y, M, w, h, m, s, T, u, n (per questdb/questdb#6711) - Document optional brackets for date variable expressions - Add grammar summary section for LLM/machine parsing - Clarify $now (point-in-time) vs $today (full day interval) semantics - Consolidate time units into single reference table with Duration/Arithmetic columns - Reorder Quick start to lead with common relative patterns ($now - 1h..$now) - Add Real-time monitoring examples section - Improve Ranges vs durations explanation - Remove redundant sections, reduce duplication Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
@CodeRabbit pls review |
|
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@core/src/main/java/io/questdb/griffin/model/IntervalUtils.java`:
- Around line 678-732: The bare date-variable scanner in the if-block anchored
by effectiveSeqLo incorrectly treats 'T' as an unconditional suffix and also
permits unbracketed comma lists; update the while-loop that computes exprEnd so
it does not break on 'T' unless that 'T' is the start of a time-of-day suffix
(e.g., followed by a digit or ':'), and add ',' to the set of stop characters so
we don't accept comma-separated lists without brackets; after the loop, if the
next char is ',' throw an SqlException (or otherwise reject) with a clear
message that comma lists require brackets; make these changes around the
variables effectiveSeq, exprEnd and wrappedSink and ensure expandDateList is
only called when a valid single bare expression was captured.
|
@CodeRabbit i fixed the issue and added more tests. Please check. |
|
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@core/src/main/java/io/questdb/griffin/model/IntervalUtils.java`:
- Around line 2157-2180: The time-precision branch incorrectly calls
applyTimezoneToIntervals(..., true) unconditionally which corrupts metadata when
applyEncoded is false and fails to honor a global timezone suffix; modify the
branch in IntervalUtils (around encodeInterval, applyEncoded,
findTimezoneMarker) to resolve the active timezone the same way the day-based
path does (considering global suffix and dynamic resolution) and pass the actual
applyEncoded flag into applyTimezoneToIntervals instead of true; ensure you use
the same tz marker discovery (findTimezoneMarker(seq, rangeEnd, elementEnd)) but
when no element-level TZ is found fall back to the same active-TZ resolution
used by the day-based path, then call applyTimezoneToIntervals(timestampDriver,
configuration, out, outSizeBeforeInterval, seq, tzLo, elementEnd, errorPos,
applyEncoded).
|
@CodeRabbit the bugs you reported have been fixed. Please review and resolve comments if you agree. |
|
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@core/src/main/java/io/questdb/griffin/model/IntervalUtils.java`:
- Around line 2157-2204: The time-precision branch applies timezone conversion
before applying day filters, causing dayFilterMask (local-time semantics) to be
evaluated in UTC; to fix, when hasTimePrecision is true move the day-filter
handling so that if dayFilterMask != 0 you call applyDayFilter(...) (for
applyEncoded==true) or setDayFilterMaskOnEncodedIntervals(...) (for
applyEncoded==false) immediately after encoding and before calling
applyTimezoneToIntervals(...); keep using outSizeBeforeInterval, out,
timestampDriver, applyEncoded, dayFilterMask, seq and activeTzLo/activeTzHi
exactly as currently computed, then proceed to applyTimezoneToIntervals(...)
only afterwards.
|
@CodeRabbit all bugs should be fixed. Please review and resolve comments. Find more bugs! |
|
Note: I see there's an enterprise CI failure reported by questdb-butler that will need to be investigated before merge. 🧠 Learnings used✅ Actions performedReview triggered.
|
|
@CodeRabbit, don't forget about me, i am waiting for your feedback! |
|
✅ 100% test coverage achieved on all modified files (82/82 lines covered) I'll review the latest changes now to provide feedback on the implementation and verify the fixes. ✅ Actions performedReview triggered.
|
|
@CodeRabbit i fixed bug for |
|
I'll review the latest changes now and resolve my previous comments where the bugs have been properly fixed. I'll verify:
Current status: ✅ Actions performedReview triggered.
|
[PR Coverage check]😍 pass : 84 / 84 (100.00%) file detail
|
|
@CodeRabbit don't give up on me |
|
Your achievements on this PR: Remaining items before merge:
Next steps:
Let me trigger a thorough review now to ensure everything is in great shape! 🧠 Learnings used✅ Actions performedReview triggered.
|
|
@CodeRabbit Enterprise CI failure wasn't related and it is resolved. |
|
PR Status Summary: ✅ 100% test coverage (84/84 lines covered) Outstanding work! This is a substantial enhancement to the TICK date variable arithmetic system with excellent coverage and thorough testing. The PR is now ready for final review and approval by your team's human reviewers. I'll conduct a final comprehensive review now to ensure everything is in order for merge. ✅ Actions performedReview triggered.
|
Summary
Extends the TICK (Temporal Interval Calendar Kit) date variable arithmetic to support additional time units beyond days and business days. This enables precise timestamp arithmetic in interval expressions.
New Time Units
y$today + 1yM$today + 3Mw$today + 2wd$today + 5dbd$today + 5bdh$now - 2hm$now + 30ms$now + 90sT$now + 500Tu$now + 100un$now + 1000nOptional Brackets
Date variable expressions can now be written with or without brackets:
Usage Examples
Hour-based queries
Minute-based queries
Second-based queries
Sub-second precision
Calendar-aware units
Combined with other TICK features
Behavior Notes
$nowwith sub-day units (h, m, s, T, u, n), the result preserves full microsecond/nanosecond precision and produces point-in-time intervalsy(years) andM(months) properly handle varying month lengths and leap yearsdunit is case-insensitive (Dalso works) for backward compatibility$start..$end) iterate at day granularity regardless of the arithmetic units usedTest plan
dandbdunits🤖 Generated with Claude Code