[GLUTEN-11622][VL] Fallback TimestampNTZ to Spark#11609
Conversation
afc463d to
62c6a55
Compare
|
Run Gluten Clickhouse CI on x86 |
|
Run Gluten Clickhouse CI on x86 |
|
@rui-mo can you please review this PR? Thanks in advance! |
|
Run Gluten Clickhouse CI on x86 |
Thank you for the review! This PR fixes the SparkArrowUtil Arrow type mapping so that the RTC transitions at fallback boundaries don't crash with UnsupportedOperationException. The flow is:
|
|
@acvictor Thank you for the additional information. I’m still a bit unclear: in a plan like |
I added debug logs to Gluten and used the example of the test op1 here would be ColumnarCollectLimitExec. The actual runtime plan is: VeloxColumnarToRowExec Debug logs added to Transitions.scala confirm it: ColumnarCollectLimitExec appears despite the FallbackByTimestampNTZ validator because it is registered as a post-transform rule, which runs after validation. It sees the vanilla CollectLimitExec with a columnar child and unconditionally replaces it with ColumnarCollectLimitExec bypassing the validator entirely. Then InsertTransitions sees a convention mismatch (VanillaBatch - VeloxBatch) and inserts the RowToVeloxColumnarExec, which throws an exception in SparkArrowUtil.toArrowSchema because there is no case for TimestampNTZType. The validator alone cannot handle this because post-transform rules like CollectLimitTransformerRule can reintroduce Gluten native operators after validation has already run. |
@acvictor Thanks for providing the detailed query plan. For this patch, to make the |
Is this because the type is treated during conversion simply as an Arrow timestamp without a timezone? - Yes that's right! I was able to get all OSS Delta tests to pass with this change as well as Spark and Gluten UTs and have not found any issue so far. |
What changes are proposed in this pull request?
TimestampNTZ is not fully supported in Velox. This PR adds a FallbackByTimestampNTZ validator that unconditionally falls back any operator whose input or output schema contains TimestampNTZType.
The Arrow type mapping for TimestampNTZType is added in SparkArrowUti and is required because RowToVeloxColumnarExec transitions are inserted after the validation phase at RTC boundaries, and these call SparkArrowUtil.toArrowSchema which must be able to handle all types present in the schema. Without this mapping, the transition crashes with UnsupportedOperationException even though the operator itself was correctly fallen back.
How was this patch tested?
Added UTs in VeloxParquetDataTypeValidationSuite and DeltaSuite to verify that TimestampNTZ scans fall back to Spark and return correct results, and also added tests for Delta tables with NTZ columns, NTZ partition columns, and filters on NTZ columns were we originally saw the UnsupportedOperationException being thrown.
Was this patch authored or co-authored using generative AI tooling?
No
Related issue: #11622