yiyutian1 commented on code in PR #25763:
URL: https://github.com/apache/flink/pull/25763#discussion_r1891231957
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/scalar/ToTimestampLtzFunction.java:
##########
@@ -89,46 +94,41 @@ public
ToTimestampLtzFunction(SpecializedFunction.SpecializedContext context) {
}
public @Nullable TimestampData eval(Number epoch) {
- if (epoch == null) {
- return null;
- }
- if (epoch instanceof Float || epoch instanceof Double) {
- return DateTimeUtils.toTimestampData(epoch.doubleValue());
- }
- return DateTimeUtils.toTimestampData(epoch.longValue());
+ return eval(epoch, DEFAULT_PRECISION);
}
- public TimestampData eval(DecimalData epoch) {
- if (epoch == null) {
- return null;
- }
-
- return DateTimeUtils.toTimestampData(epoch);
+ public @Nullable TimestampData eval(DecimalData epoch) {
+ return eval(epoch, DEFAULT_PRECISION);
}
public @Nullable TimestampData eval(StringData timestamp) {
if (timestamp == null) {
return null;
}
- return DateTimeUtils.parseTimestampData(timestamp.toString());
+ return parseTimestampData(timestamp.toString());
}
public @Nullable TimestampData eval(StringData timestamp, StringData
format) {
if (timestamp == null || format == null) {
return null;
}
- return DateTimeUtils.parseTimestampData(timestamp.toString(),
format.toString());
+ return parseTimestampData(timestamp.toString(), format.toString());
}
public @Nullable TimestampData eval(
- StringData timestamp, StringData format, StringData timezone) {
- if (timestamp == null || format == null || timezone == null) {
Review Comment:
move the logic into from `DateTimeUtils.java` to
`ToTimestampLtzFunction.java` to reduce redundant function calling.
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/scalar/ToTimestampLtzFunction.java:
##########
@@ -89,46 +94,41 @@ public
ToTimestampLtzFunction(SpecializedFunction.SpecializedContext context) {
}
public @Nullable TimestampData eval(Number epoch) {
- if (epoch == null) {
- return null;
- }
- if (epoch instanceof Float || epoch instanceof Double) {
- return DateTimeUtils.toTimestampData(epoch.doubleValue());
- }
- return DateTimeUtils.toTimestampData(epoch.longValue());
+ return eval(epoch, DEFAULT_PRECISION);
}
- public TimestampData eval(DecimalData epoch) {
- if (epoch == null) {
- return null;
- }
-
- return DateTimeUtils.toTimestampData(epoch);
+ public @Nullable TimestampData eval(DecimalData epoch) {
+ return eval(epoch, DEFAULT_PRECISION);
}
public @Nullable TimestampData eval(StringData timestamp) {
if (timestamp == null) {
return null;
}
- return DateTimeUtils.parseTimestampData(timestamp.toString());
+ return parseTimestampData(timestamp.toString());
}
public @Nullable TimestampData eval(StringData timestamp, StringData
format) {
if (timestamp == null || format == null) {
return null;
}
- return DateTimeUtils.parseTimestampData(timestamp.toString(),
format.toString());
+ return parseTimestampData(timestamp.toString(), format.toString());
}
public @Nullable TimestampData eval(
- StringData timestamp, StringData format, StringData timezone) {
- if (timestamp == null || format == null || timezone == null) {
Review Comment:
moved the logic into from `DateTimeUtils.java` to
`ToTimestampLtzFunction.java` to reduce redundant function calling.
--
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]