JingsongLi commented on code in PR #1806:
URL: https://github.com/apache/incubator-paimon/pull/1806#discussion_r1292918181
##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/action/cdc/Expression.java:
##########
@@ -239,6 +251,36 @@ public String eval(String input) {
}
}
+ /** date format from a time input. */
+ final class DateFormat implements Expression {
+
+ private static final long serialVersionUID = 1L;
+
+ private final String fieldReference;
+ private final String pattern;
+
+ private DateFormat(String fieldReference, String pattern) {
+ this.fieldReference = fieldReference;
+ this.pattern = pattern;
+ }
+
+ @Override
+ public String fieldReference() {
+ return fieldReference;
+ }
+
+ @Override
+ public DataType outputType() {
+ return DataTypes.STRING();
+ }
+
+ @Override
+ public String eval(String input) {
+ LocalDateTime localDateTime = DateTimeUtils.toLocalDateTime(input,
0);
+ return localDateTime.format(DateTimeFormatter.ofPattern(pattern));
Review Comment:
We should reuse pattern, `DateTimeFormatter.ofPattern(pattern)` could be a
class field.
--
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]