-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[fix](fe) Preserve TIMESTAMPTZ user variable type #66833
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 |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| package org.apache.doris.qe; | ||
|
|
||
| import org.apache.doris.analysis.BoolLiteral; | ||
| import org.apache.doris.analysis.DateLiteral; | ||
| import org.apache.doris.analysis.DecimalLiteral; | ||
| import org.apache.doris.analysis.FloatLiteral; | ||
| import org.apache.doris.analysis.IntLiteral; | ||
|
|
@@ -670,6 +671,8 @@ public void setUserVar(String name, LiteralExpr value) { | |
| return Literal.of(((FloatLiteral) literalExpr).getValue()); | ||
| } else if (literalExpr instanceof DecimalLiteral) { | ||
| return Literal.of(((DecimalLiteral) literalExpr).getValue()); | ||
| } else if (literalExpr instanceof DateLiteral) { | ||
| return Literal.fromLegacyLiteral(literalExpr, literalExpr.getType()); | ||
|
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] Include TIMESTAMPTZ microseconds in literal comparison This branch makes user variables reach FE folding as
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] Keep chained user-variable casts foldable After this returns a
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] Preserve TIMESTAMPTZ in legacy comparison coercion With the supported global
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] Preserve TIMESTAMPTZ in legacy result coercion The legacy common-result path is separate from comparison coercion and is also exposed by returning typed values here. With |
||
| } else if (literalExpr instanceof StringLiteral) { | ||
| return Literal.of(((StringLiteral) literalExpr).getValue()); | ||
| } else if (literalExpr instanceof NullLiteral) { | ||
|
|
||
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] Preserve the type across forwarded user variables
This only fixes the in-process path. A user can
SET @v = CAST(... AS TIMESTAMPTZ(6))on a follower and then have the query forwarded when that FE cannot read or is configured to forward.FEOpExecutorsends aTExprNodewhosetypeis still TIMESTAMPTZ(6), butConnectProcessor.getLiteralExprFromThriftignores that field and reparsesnode.date_literal.valuewith a null type before this branch runs. The value therefore arrives here as DATE/DATETIME(V2), so rendering loses the offset and a DST-fold predicate is coerced to wall-clock DATETIMEV2 semantics and can return the wrong rows. Please decodenode.typeincluding its TIMESTAMPTZ scale (Type.fromThriftcurrently drops that scale), use it for reconstruction, and add a forced-forward round-trip covering rendering and equality.