LuciferYang commented on code in PR #38873:
URL: https://github.com/apache/spark/pull/38873#discussion_r1037892873
##########
sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/ColumnVectorUtils.java:
##########
@@ -125,32 +122,37 @@ public static Map<Integer, Integer>
toJavaIntMap(ColumnarMap map) {
}
private static void appendValue(WritableColumnVector dst, DataType t, Object
o) {
+ PhysicalDataType pdt = t.physicalDataType();
if (o == null) {
- if (t instanceof CalendarIntervalType) {
+ if (pdt instanceof PhysicalCalendarIntervalType) {
dst.appendStruct(true);
} else {
dst.appendNull();
}
} else {
- if (t == DataTypes.BooleanType) {
+ if (pdt instanceof PhysicalBooleanType) {
dst.appendBoolean((Boolean) o);
- } else if (t == DataTypes.ByteType) {
+ } else if (pdt instanceof PhysicalByteType) {
dst.appendByte((Byte) o);
- } else if (t == DataTypes.ShortType) {
+ } else if (pdt instanceof PhysicalShortType) {
dst.appendShort((Short) o);
- } else if (t == DataTypes.IntegerType) {
- dst.appendInt((Integer) o);
- } else if (t == DataTypes.LongType) {
+ } else if (pdt instanceof PhysicalIntegerType) {
+ if (o instanceof Date) {
+ dst.appendInt(DateTimeUtils.fromJavaDate((Date) o));
Review Comment:
https://github.com/apache/spark/blob/5d90f9825bc5aad1cf24b773586cba5309ee6caa/sql/catalyst/src/main/scala/org/apache/spark/sql/Row.scala#L170-L174
Except for `java.sql.Timestamp`, I think we should also handle `o` is
`java.time.LocalDate` and `java.time.Instant` ref the document.?
There should be no tests to cover these branches. I will add some test later.
##########
sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/ColumnVectorUtils.java:
##########
@@ -125,32 +122,37 @@ public static Map<Integer, Integer>
toJavaIntMap(ColumnarMap map) {
}
private static void appendValue(WritableColumnVector dst, DataType t, Object
o) {
+ PhysicalDataType pdt = t.physicalDataType();
if (o == null) {
- if (t instanceof CalendarIntervalType) {
+ if (pdt instanceof PhysicalCalendarIntervalType) {
dst.appendStruct(true);
} else {
dst.appendNull();
}
} else {
- if (t == DataTypes.BooleanType) {
+ if (pdt instanceof PhysicalBooleanType) {
dst.appendBoolean((Boolean) o);
- } else if (t == DataTypes.ByteType) {
+ } else if (pdt instanceof PhysicalByteType) {
dst.appendByte((Byte) o);
- } else if (t == DataTypes.ShortType) {
+ } else if (pdt instanceof PhysicalShortType) {
dst.appendShort((Short) o);
- } else if (t == DataTypes.IntegerType) {
- dst.appendInt((Integer) o);
- } else if (t == DataTypes.LongType) {
+ } else if (pdt instanceof PhysicalIntegerType) {
+ if (o instanceof Date) {
+ dst.appendInt(DateTimeUtils.fromJavaDate((Date) o));
Review Comment:
https://github.com/apache/spark/blob/5d90f9825bc5aad1cf24b773586cba5309ee6caa/sql/catalyst/src/main/scala/org/apache/spark/sql/Row.scala#L170-L174
Except for `java.sql.Timestamp`, I think we should also handle `o` is
`java.time.LocalDate` and `java.time.Instant` ref to the document.?
There should be no tests to cover these branches. I will add some test later.
--
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]