Replies: 4 comments 2 replies
|
Hi @Yuhta @mbasmanova @pedroerp, based on the above context, what do you think about the proposal to add the |
|
Is |
|
Hi all, |
|
Thanks for the detailed writeup, @rui-mo. If I understand the proposal correctly: add This would give you:
Note that the Parquet conversion overhead ( If that's what you have in mind, I'm fine with this approach. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Although Presto and Spark expose similarly named timestamp types, their semantics differ significantly. Since both engines reuse the
Timestampimplementation in Velox, it is necessary to clearly understand the differences at the type level.Presto’s TimestampType type is typically stored as a long value representing milliseconds, and it is interpreted with respect to a session time zone. In contrast, Spark’s TimestampType is stored as a long value representing microseconds, also timezone-aware. Both reuse the same underlying Velox representation
Timestamp, and they differ only in precision.Presto’s timestamp with time zone encodes a value as UTC milliseconds plus a time zone key. This allows each row to represent a fully qualified point in time. In Velox, this is supported via a dedicated Presto custom type.
Spark’s TimestampNTZType is also stored as a long value in microseconds, but it is timezone–agnostic. As such, it is not semantically equivalent to any of above timestamp types.
When it comes to storage in Apache Parquet, the differences become more apparent. Parquet defines timestamp columns using parameters such as
isAdjustedToUTCandtimeUnit. Spark relies on these annotations for interpretation:isAdjustedToUTC= true, Spark interprets the column asTimestampType.isAdjustedToUTC= false, Spark interprets it asTimestampNTZType.For example:
Timestamp(isAdjustedToUTC = false, timeUnit = microseconds)This means the data is stored as microseconds and will be read as
TimestampNTZTypein Spark.To support this type in Gluten, we initially attempted to add a custom TimestampNTZType in Velox specifically for Spark. However, we encountered several issues:
Reading these values as Velox’s
Timestamp(int64_t seconds, uint64_t nanos)and converting them into int64_t would introduce extra overhead due to the multiple conversion steps:micros(int64_t) → seconds + nanos → micros(int64_t).Based on above, an alternative approach we are considering is extending the existing Velox
Timestamptype to add aTimestampUTCtype, similar to howTimeandTimeUTCare handled. This would allow us to reuse most of the existingTimestampreader implementations, reducing complexity and overhead.Looking forward to your thoughts and insights, thank you.
cc: @Yuhta @mbasmanova @pedroerp
All reactions