JNSimba commented on code in PR #377:
URL:
https://github.com/apache/doris-spark-connector/pull/377#discussion_r3910382411
##########
spark-doris-connector/spark-doris-connector-base/src/main/java/org/apache/doris/spark/client/read/RowBatch.java:
##########
@@ -424,46 +424,48 @@ public void convertArrowToRowBatch() throws
DorisException {
break;
case "DATETIME":
case "DATETIMEV2":
- case "TIMESTAMPTZ":
-
if (mt.equals(MinorType.VARCHAR)) {
- VarCharVector varCharVector = (VarCharVector)
curFieldVector;
- for (int rowIndex = 0; rowIndex <
rowCountInOneBatch; rowIndex++) {
- if (varCharVector.isNull(rowIndex)) {
- addValueToRow(rowIndex, null);
- continue;
- }
- String stringValue = completeMilliseconds(new
String(varCharVector.get(rowIndex),
- StandardCharsets.UTF_8));
- LocalDateTime dateTime =
LocalDateTime.parse(stringValue, dateTimeV2Formatter);
- if (datetimeJava8ApiEnabled) {
- Instant instant =
dateTime.atZone(DEFAULT_ZONE_ID).toInstant();
- addValueToRow(rowIndex, instant);
- } else {
- addValueToRow(rowIndex,
Timestamp.valueOf(dateTime));
- }
- }
+ convertVarcharDateTime((VarCharVector)
curFieldVector);
} else if (curFieldVector instanceof TimeStampVector) {
TimeStampVector timeStampVector =
(TimeStampVector) curFieldVector;
+ ArrowType.Timestamp timestampType =
+ (ArrowType.Timestamp)
timeStampVector.getField().getType();
+ String timezone = timestampType.getTimezone();
+ ZoneId zoneId = timezone == null ? null :
ZoneId.of(timezone);
Review Comment:
getDateTime() already reads ArrowType.Timestamp and its timezone from the
vector. Could we add an overload that accepts a ZoneId override?
DATETIME/DATETIMEV2 could use the timezone from the Arrow schema when no
override is provided, while TIMESTAMPTZ could explicitly pass DEFAULT_ZONE_ID
to preserve its current instant semantics. This would avoid resolving
timestampType and timezone again at the call site.
--
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]