github-actions[bot] commented on code in PR #65219:
URL: https://github.com/apache/doris/pull/65219#discussion_r3655556846
##########
fe/fe-core/src/main/java/org/apache/doris/analysis/ExprToStringValueVisitor.java:
##########
@@ -56,11 +56,29 @@ public String visitDateLiteral(DateLiteral expr,
StringValueContext ctx) {
String value;
if (expr.getType().isTimeStampTz()) {
try {
- ZoneId dorisZone = DateUtils.getTimeZone();
- String offset =
dorisZone.getRules().getOffset(java.time.Instant.now()).toString();
- DateLiteral dateLiteral =
DateLiteralUtils.createDateLiteral(expr.getStringValue(),
- ScalarType.createDatetimeV2Type(((ScalarType)
expr.getType()).getScalarScale()));
- value = dateLiteral.getStringValue() + offset;
+ if (ctx.isForStreamLoad()) {
+ // BE's TIMESTAMPTZ parser consumes only hour/minute
offsets
+ // (minutes restricted to 00/30/45). Historical zone
offsets
+ // can include seconds (e.g. Asia/Shanghai before 1901 had
+ // +08:05:43), which BE would reject. Since TIMESTAMPTZ
+ // stores UTC internally, render in UTC format that BE can
+ // round-trip.
+ value = expr.getStringValue();
+ } else {
+ ZoneId dorisZone = DateUtils.getTimeZone();
+ // Compute offset from the target instant (the literal's
UTC
+ // value), not Instant.now() which may be in a different
DST
+ // period.
+ java.time.Instant targetInstant =
java.time.LocalDateTime.of(
+ (int) expr.getYear(), (int) expr.getMonth(), (int)
expr.getDay(),
+ (int) expr.getHour(), (int) expr.getMinute(),
(int) expr.getSecond(),
+ (int) expr.getMicrosecond() * 1000)
+ .atZone(java.time.ZoneOffset.UTC).toInstant();
+ String offset =
dorisZone.getRules().getOffset(targetInstant).toString();
Review Comment:
[P2] Keep historical TIMESTAMPTZ query output consistent across FE and BE
For `1900-01-01T00:00:00Z` in `Asia/Shanghai`, this branch makes FE constant
evaluation emit `1900-01-01 08:05:43+08:05:43`. Materialized rows take the BE
serializer instead: `TimestampTzValue::to_string()` keeps the `08:05:43` wall
clock but drops the offset seconds and emits `+08:05`. The same stored instant
therefore returns different text depending on whether `PhysicalOneRowRelation`
computes it in FE or BE serializes a row, and the BE form denotes a different
instant if reparsed. Please define one exact result contract across both paths
(for example, use UTC for historical offsets until BE supports offset seconds
end to end) and add an FE-vs-BE regression.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]