fix(isthmus)!: write the output type the datetime extension declares - #1346
nielspardon merged 5 commits into
Conversation
Calcite to Substrait took a function's output type from the Calcite call, so date - INTERVAL '5' DAY wrote subtract:date_iday returning date, where the extension declares precision_timestamp<P>, and TIMESTAMP(3) minus an interval_day<6> bound P to two values. For the datetime extension the call now carries the declared type, and a cast returns the column to Calcite's type where the two differ. Where one parameter would bind two precisions, the narrower operand is widened first, which is lossless for a timestamp and an interval alike.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: substrait-io/substrait-java/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review. 📝 SummarySummary by CodeRabbit
WalkthroughDatetime scalar function conversion now resolves datetime-extension output types from argument types and adjusts supported argument precisions. Date-output addition and subtraction handle day interval operands, including truncation of sub-day literal fields. Tests cover datetime comparisons, expression types and casts, interval arithmetic, and conversion round trips. ChangesDatetime conversion
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to No concrete merge-blocking issue is identified. The datetime conversion changes appear ready to merge subject to normal build and test checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change adds datetime casts and new rejection cases that consumers must handle. The inspected conversion path does not introduce privileged operations or external execution, but downstream service exposure and deployment compatibility remain unestablished. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
nielspardon
left a comment
There was a problem hiding this comment.
Two things before the rest: restrict the operand widening to the declarations whose P reaches the result, and decide what date ± interval_day should do with a sub-day interval. Everything else is smaller and can wait for the next round.
nielspardon
left a comment
There was a problem hiding this comment.
Thanks, the DATE handling is exactly it. Below is the next round. Please also change #1117 in the PR body to the full issue URL, because semantic-release renders a bare reference as "closes #1117" in the changelog while the issue stays open.
nielspardon
left a comment
There was a problem hiding this comment.
Thanks, all five are fixed. The last few are small.
|
Fixed all five and added round-trip tests. |
|
@coderabbitai resume |
|
Datetime calls use the extension's declared result type. Casts preserve Calcite's inferred types, except for dynamic placeholders. Literals are widened directly, and interval casts use SQL qualifiers.
For DATE results, sub-day literals are truncated to whole days toward zero, and non-literal sub-day intervals are rejected. Timestamp results keep the full interval.
This is the datetime part of #1117.
BREAKING CHANGE: Consumers must handle added datetime casts. Conversion rejects DATE arithmetic with non-literal sub-day intervals, unsupported timestamp precision, and literal widening overflow.