-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[fix](TIMESTAMPTZ) Preserve TIMESTAMPTZ for microsecond interval arithmetic #66843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,10 +41,10 @@ public class DayMicrosecondAdd extends ScalarFunction | |
| implements BinaryExpression, ExplicitlyCastableSignature, | ||
| ComputeSignatureForDateArithmetic, PropagateNullable, DateAddSubMonotonic { | ||
| public static final List<FunctionSignature> SIGNATURES = ImmutableList.of( | ||
| FunctionSignature.ret(DateTimeV2Type.MAX) | ||
| .args(DateTimeV2Type.MAX, VarcharType.SYSTEM_DEFAULT), | ||
| FunctionSignature.ret(TimeStampTzType.MAX) | ||
| .args(TimeStampTzType.MAX, VarcharType.SYSTEM_DEFAULT) | ||
| FunctionSignature.ret(DateTimeV2Type.WILDCARD) | ||
| .args(DateTimeV2Type.WILDCARD, VarcharType.SYSTEM_DEFAULT), | ||
| FunctionSignature.ret(TimeStampTzType.WILDCARD) | ||
| .args(TimeStampTzType.WILDCARD, VarcharType.SYSTEM_DEFAULT) | ||
| ); | ||
|
|
||
| public DayMicrosecondAdd(Expression arg0, Expression arg1) { | ||
|
|
@@ -80,6 +80,9 @@ public Expression withConstantArgs(Expression literal) { | |
| @Override | ||
| public FunctionSignature computeSignature(FunctionSignature signature) { | ||
| signature = super.computeSignature(signature); | ||
| if (signature.argumentsTypes.get(0) instanceof TimeStampTzType) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P1] Select the TIMESTAMPTZ family before forcing scale 6 For the test's Thus typed TIMESTAMPTZ columns, casts, and literals at scales 0-5 still take the old session-local DATETIMEV2 path in all six changed classes; only scale 6 and zoned string literals reach this branch. Please use wildcard-scale family signatures (the established sibling pattern), or otherwise preserve the typed family during selection without regressing the existing zoned-string selection, before promoting the selected family to scale 6. Also cover typed scales below 6. |
||
| return signature.withArgumentType(0, TimeStampTzType.MAX).withReturnType(TimeStampTzType.MAX); | ||
| } | ||
| return signature.withArgumentType(0, DateTimeV2Type.MAX).withReturnType(DateTimeV2Type.MAX); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| -- This file is automatically generated. You should know what you did if you want to edit this | ||
| -- !timestamptz_microsecond_interval_scale_0 -- | ||
| 1 2024-01-03 05:07:09.123456+08:00 2024-01-01 01:01:00.876544+08:00 2024-01-02 05:07:09.123456+08:00 2024-01-02 01:01:00.876544+08:00 2024-01-02 03:07:09.123456+08:00 2024-01-02 03:01:00.876544+08:00 2024-01-02 03:04:09.123456+08:00 2024-01-02 03:04:00.876544+08:00 2024-01-02 03:04:05.123456+08:00 2024-01-02 03:04:04.876544+08:00 2024-01-02 03:04:05.123000+08:00 2024-01-02 03:04:04.877000+08:00 | ||
|
|
||
| -- !timestamptz_microsecond_interval_scale_3 -- | ||
| 1 2024-01-03 05:07:09.246456+08:00 2024-01-01 01:01:00.999544+08:00 2024-01-02 05:07:09.246456+08:00 2024-01-02 01:01:00.999544+08:00 2024-01-02 03:07:09.246456+08:00 2024-01-02 03:01:00.999544+08:00 2024-01-02 03:04:09.246456+08:00 2024-01-02 03:04:00.999544+08:00 2024-01-02 03:04:05.246456+08:00 2024-01-02 03:04:04.999544+08:00 2024-01-02 03:04:05.246000+08:00 2024-01-02 03:04:05.000000+08:00 | ||
|
|
||
| -- !timestamptz_microsecond_interval_scale_6 -- | ||
| 1 2024-01-03 05:07:09.246912+08:00 2024-01-01 01:01:01.000000+08:00 2024-01-02 05:07:09.246912+08:00 2024-01-02 01:01:01.000000+08:00 2024-01-02 03:07:09.246912+08:00 2024-01-02 03:01:01.000000+08:00 2024-01-02 03:04:09.246912+08:00 2024-01-02 03:04:01.000000+08:00 2024-01-02 03:04:05.246912+08:00 2024-01-02 03:04:05.000000+08:00 2024-01-02 03:04:05.246456+08:00 2024-01-02 03:04:05.000456+08:00 | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Cover the remaining scale-promoting TIMESTAMPTZ siblings
These wildcard signatures fix the six day/hour/minute classes, but
SecondMicrosecondAdd/Sub,MicroSecondsAdd/Sub, andMilliSecondsAdd/Substill declare the ordered concrete pairDATETIMEV2(6)thenTIMESTAMPTZ(6). For example, a typed scale-3 column still binds as:Neither concrete signature is identical for scales 0-5, both tie in the implicit round, and search keeps the first DATETIMEV2 candidate before those classes inspect the selected family. All six paths are reachable and already have dedicated TIMESTAMPTZ FE/BE overloads, so they still return the wrong family and use session-local DATETIMEV2 semantics. This is distinct from the earlier thread, which covered only the six changed classes. Please use family wildcard signatures for these siblings too and extend the typed scale-0/3/6 type/runtime matrix to cover them.