uros-b commented on code in PR #56807:
URL: https://github.com/apache/spark/pull/56807#discussion_r3480763228
##########
connector/protobuf/src/main/scala/org/apache/spark/sql/protobuf/ProtobufDeserializer.scala:
##########
@@ -235,6 +235,11 @@ private[sql] class ProtobufDeserializer(
case (LONG, LongType) =>
(updater, ordinal, value) => updater.setLong(ordinal,
value.asInstanceOf[Long])
+ case (LONG, _: TimeType) =>
+ // The int64 field stores nanoseconds-of-day, matching TimeType's
internal
+ // nanos-since-midnight representation, so copy the value directly.
+ (updater, ordinal, value) => updater.setLong(ordinal,
value.asInstanceOf[Long])
Review Comment:
On another note: it seems that the deserializer branch is effectively
unreachable from the public API. from_protobuf always derives its output schema
from the descriptor via SchemaConverters.toSqlType, which yields LongType for
an int64 (the PR correctly documents this). So this (LONG, TimeType) case is
never hit by from_protobuf and is only reachable by constructing a
ProtobufDeserializer directly with an explicit TimeType catalyst schema; which
is exactly (and only) what the second test does.
The PR description slightly oversells it ("the int64 -> TimeType
deserializer path is exercised when..."), so it would be good to confirm
whether any non-test code path ever supplies an explicit TimeType schema to the
deserializer; if not, this is essentially test-only code.
--
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]