dmitry-chirkov-dremio commented on code in PR #1081:
URL: https://github.com/apache/arrow-java/pull/1081#discussion_r2969799814
##########
flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/converter/impl/TimestampAvaticaParameterConverter.java:
##########
@@ -33,11 +35,79 @@
/** AvaticaParameterConverter for Timestamp Arrow types. */
public class TimestampAvaticaParameterConverter extends
BaseAvaticaParameterConverter {
- public TimestampAvaticaParameterConverter(ArrowType.Timestamp type) {}
+ private final ArrowType.Timestamp type;
+
+ public TimestampAvaticaParameterConverter(ArrowType.Timestamp type) {
+ this.type = type;
+ }
+
+ /**
+ * Converts a raw java.sql.Timestamp to the value in the target Arrow time
unit, preserving
+ * sub-millisecond precision from Timestamp.getNanos().
+ */
+ private long convertFromTimestamp(Timestamp ts) {
+ // Timestamp.getTime() returns epoch millis (truncated, no sub-ms
precision).
+ // Timestamp.getNanos() returns the fractional-second component in
nanoseconds (0..999_999_999).
+ // We reconstruct the full-precision value from epoch seconds + nanos to
avoid double-counting.
+ long epochSeconds = Math.floorDiv(ts.getTime(), 1_000L);
+ int nanos = ts.getNanos(); // 0..999_999_999, full fractional second
+ switch (type.getUnit()) {
+ case SECOND:
+ return epochSeconds;
+ case MILLISECOND:
+ return epochSeconds * 1_000L + nanos / 1_000_000;
+ case MICROSECOND:
+ return epochSeconds * 1_000_000L + nanos / 1_000;
+ case NANOSECOND:
+ return epochSeconds * 1_000_000_000L + nanos;
+ default:
+ throw new UnsupportedOperationException("Unsupported time unit: " +
type.getUnit());
+ }
+ }
+
+ /** Converts an epoch millisecond value from Avatica to the target time
unit. */
+ private long convertFromMillis(long epochMillis) {
+ switch (type.getUnit()) {
+ case SECOND:
+ return epochMillis / 1_000L;
Review Comment:
@jbonofre @xborder addressed your feedback in 5th commit
--
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]