TyrantLucifer commented on code in PR #2637:
URL:
https://github.com/apache/incubator-seatunnel/pull/2637#discussion_r962324425
##########
seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/common/serialization/InternalRowConverter.java:
##########
@@ -74,13 +76,12 @@ private static Object convert(Object field,
SeaTunnelDataType<?> dataType) {
SeaTunnelRowType rowType = (SeaTunnelRowType) dataType;
return convert(seaTunnelRow, rowType);
case DATE:
- return Date.valueOf((LocalDate) field);
+ return (int) ((LocalDate) field).toEpochDay();
case TIME:
- //TODO: how reconvert?
LocalTime localTime = (LocalTime) field;
- return
Timestamp.valueOf(LocalDateTime.of(LocalDate.ofEpochDay(0), localTime));
+ return (LocalDateTime.of(LocalDate.ofEpochDay(0),
localTime).toInstant(ZONE_UTC)).toEpochMilli();
Review Comment:
The same as above.
##########
seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/common/serialization/InternalRowConverter.java:
##########
@@ -164,11 +168,11 @@ private static Object reconvert(Object field,
SeaTunnelDataType<?> dataType) {
case ROW:
return reconvert((InternalRow) field, (SeaTunnelRowType)
dataType);
case DATE:
- return ((Date) field).toLocalDate();
+ return LocalDate.ofEpochDay((int) field);
case TIME:
- return ((Timestamp) field).toLocalDateTime().toLocalTime();
+ return LocalDateTime.ofInstant(Instant.ofEpochMilli((long)
field), ZONE_UTC).toLocalTime();
case TIMESTAMP:
- return ((Timestamp) field).toLocalDateTime();
+ return LocalDateTime.ofInstant(Instant.ofEpochMilli((long)
field), ZONE_UTC);
Review Comment:
The same as above.
##########
seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/common/serialization/InternalRowConverter.java:
##########
@@ -164,11 +168,11 @@ private static Object reconvert(Object field,
SeaTunnelDataType<?> dataType) {
case ROW:
return reconvert((InternalRow) field, (SeaTunnelRowType)
dataType);
case DATE:
- return ((Date) field).toLocalDate();
+ return LocalDate.ofEpochDay((int) field);
Review Comment:
The same as above.
##########
seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/common/serialization/InternalRowConverter.java:
##########
@@ -74,13 +76,12 @@ private static Object convert(Object field,
SeaTunnelDataType<?> dataType) {
SeaTunnelRowType rowType = (SeaTunnelRowType) dataType;
return convert(seaTunnelRow, rowType);
case DATE:
- return Date.valueOf((LocalDate) field);
+ return (int) ((LocalDate) field).toEpochDay();
case TIME:
- //TODO: how reconvert?
LocalTime localTime = (LocalTime) field;
- return
Timestamp.valueOf(LocalDateTime.of(LocalDate.ofEpochDay(0), localTime));
+ return (LocalDateTime.of(LocalDate.ofEpochDay(0),
localTime).toInstant(ZONE_UTC)).toEpochMilli();
case TIMESTAMP:
- return Timestamp.valueOf((LocalDateTime) field);
+ return ((LocalDateTime)
field).toInstant(ZONE_UTC).toEpochMilli();
Review Comment:
The same as above.
##########
seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/common/serialization/InternalRowConverter.java:
##########
@@ -164,11 +168,11 @@ private static Object reconvert(Object field,
SeaTunnelDataType<?> dataType) {
case ROW:
return reconvert((InternalRow) field, (SeaTunnelRowType)
dataType);
case DATE:
- return ((Date) field).toLocalDate();
+ return LocalDate.ofEpochDay((int) field);
case TIME:
- return ((Timestamp) field).toLocalDateTime().toLocalTime();
+ return LocalDateTime.ofInstant(Instant.ofEpochMilli((long)
field), ZONE_UTC).toLocalTime();
Review Comment:
The same as above.
##########
seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/common/serialization/InternalRowConverter.java:
##########
@@ -74,13 +76,12 @@ private static Object convert(Object field,
SeaTunnelDataType<?> dataType) {
SeaTunnelRowType rowType = (SeaTunnelRowType) dataType;
return convert(seaTunnelRow, rowType);
case DATE:
- return Date.valueOf((LocalDate) field);
+ return (int) ((LocalDate) field).toEpochDay();
Review Comment:
What's the meaning of using `UTC` zone? I think the data should be
consistent.
--
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]