[bugfix](iceberg)Read error when timestamp does not have time zone for 2.1 (#36435)
bp: #36141
This commit is contained in:
@ -53,7 +53,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
// TODO(dhc) add nanosecond timer for coordinator's root profile
|
||||
public class TimeUtils {
|
||||
public static final String UTC_TIME_ZONE = "Europe/London"; // This is just a Country to represent UTC offset +00:00
|
||||
public static final String UTC_TIME_ZONE = "UTC"; // This is just a Country to represent UTC offset +00:00
|
||||
public static final String DEFAULT_TIME_ZONE = "Asia/Shanghai";
|
||||
public static final ZoneId TIME_ZONE;
|
||||
public static final ImmutableMap<String, String> timeZoneAliasMap;
|
||||
@ -148,6 +148,10 @@ public class TimeUtils {
|
||||
return TimeZone.getTimeZone(ZoneId.of(timezone, timeZoneAliasMap));
|
||||
}
|
||||
|
||||
public static TimeZone getUTCTimeZone() {
|
||||
return TimeZone.getTimeZone(UTC_TIME_ZONE);
|
||||
}
|
||||
|
||||
// return the time zone of current system
|
||||
public static TimeZone getSystemTimeZone() {
|
||||
return TimeZone.getTimeZone(ZoneId.of(ZoneId.systemDefault().getId(), timeZoneAliasMap));
|
||||
|
||||
@ -319,7 +319,11 @@ public class IcebergUtils {
|
||||
case DATE:
|
||||
return dateLiteral.getStringValue();
|
||||
case TIMESTAMP:
|
||||
return dateLiteral.getUnixTimestampWithMicroseconds(TimeUtils.getTimeZone());
|
||||
if (((Types.TimestampType) icebergType).shouldAdjustToUTC()) {
|
||||
return dateLiteral.getUnixTimestampWithMicroseconds(TimeUtils.getTimeZone());
|
||||
} else {
|
||||
return dateLiteral.getUnixTimestampWithMicroseconds(TimeUtils.getUTCTimeZone());
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user