Copilot commented on code in PR #12444:
URL: https://github.com/apache/gluten/pull/12444#discussion_r3522552561
##########
backends-velox/src-delta40/main/scala/org/apache/spark/sql/delta/GlutenOptimisticTransaction.scala:
##########
@@ -48,6 +49,14 @@ class GlutenOptimisticTransaction(delegate:
OptimisticTransaction)
writeOptions: Option[DeltaOptions],
isOptimize: Boolean,
additionalConstraints: Seq[Constraint]): Seq[FileAction] = {
+ // Velox has no Arrow representation for VariantType: the native write
path inserts a
+ // RowToVeloxColumnarExec transition whose SparkArrowUtil.toArrowSchema
call throws
+ // `Unsupported data type: variant` at runtime. Delegate writes whose
schema contains a
+ // variant column to the vanilla Delta write path instead of offloading
them.
+ if (inputData.schema.existsRecursively(_.isInstanceOf[VariantType])) {
+ logInfo("Input schema contains VariantType; falling back to the vanilla
Delta write path.")
+ return super.writeFiles(inputData, writeOptions, isOptimize,
additionalConstraints)
+ }
Review Comment:
The PR description says the Variant detection should be done by type name
for Spark-version/source compatibility, but this implementation relies on
`VariantType` and `isInstanceOf`. Consider switching to a type-name check (e.g.
`dt.typeName.equalsIgnoreCase("variant")`) so the guard works even if
`VariantType` isn’t available/consistent across Spark versions and to avoid
potential singleton-object `isInstanceOf` pitfalls.
##########
backends-velox/src-delta40/main/scala/org/apache/spark/sql/delta/GlutenOptimisticTransaction.scala:
##########
@@ -31,6 +31,7 @@ import org.apache.spark.sql.execution.{SparkPlan,
SQLExecution}
import org.apache.spark.sql.execution.adaptive.AdaptiveSparkPlanExec
import org.apache.spark.sql.execution.datasources.{BasicWriteJobStatsTracker,
FileFormatWriter, WriteJobStatsTracker}
import org.apache.spark.sql.internal.SQLConf
+import org.apache.spark.sql.types.VariantType
Review Comment:
If you switch the Variant detection to a `typeName` string check, this
`VariantType` import becomes unused and may fail the build if warnings are
treated as errors. Remove it accordingly.
--
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]