zhztheplayer commented on code in PR #12647:
URL: https://github.com/apache/gluten/pull/12647#discussion_r4528009677
##########
backends-velox/src-delta4/main/scala/org/apache/spark/sql/delta/GlutenOptimisticTransaction.scala:
##########
@@ -179,20 +174,31 @@ class GlutenOptimisticTransaction(delegate:
OptimisticTransaction)
partitioningColumns,
metadata)
if (nativeUnsupportedReason.isEmpty) {
- GlutenDeltaFileFormatWriter.write(
- sparkSession = spark,
- plan = glutenPhysicalPlan(
- spark, empty2NullPlan, constraints, nativeInvariantChecker,
isOptimize, writeOptions),
- fileFormat = new GlutenDeltaParquetFileFormat(protocol, metadata),
- committer = committer,
- outputSpec = outputSpec,
- hadoopConf = jobHadoopConf,
- partitionColumns = partitioningColumns,
- bucketSpec = None,
- statsTrackers = optionalStatsTracker.toSeq
- ++ statsTrackers
- ++ identityTrackerOpt.toSeq,
- options = options)
+ val glutenPlan =
+ glutenPhysicalPlan(spark, empty2NullPlan, constraints, isOptimize,
writeOptions)
+ try {
+ GlutenDeltaFileFormatWriter.write(
+ sparkSession = spark,
+ plan = glutenPlan,
+ fileFormat = new GlutenDeltaParquetFileFormat(protocol,
metadata),
+ committer = committer,
+ outputSpec = outputSpec,
+ hadoopConf = jobHadoopConf,
+ partitionColumns = partitioningColumns,
+ bucketSpec = None,
+ statsTrackers = optionalStatsTracker.toSeq
+ ++ statsTrackers
+ ++ identityTrackerOpt.toSeq,
+ options = options)
+ } catch {
+ // Native code that pulls the checked batches keeps only a
violation's text, so find
+ // the violation the plan's checker threw. Delta's own catch below
handles the rest.
+ case NonFatal(e) if
InnerInvariantViolationException.unapply(e).isEmpty =>
+ val checker = glutenPlan.collectFirst {
+ case exec: GlutenDeltaInvariantCheckerExec => exec.checker
+ }
+ throw checker.flatMap(_.findViolation(e)).getOrElse(e)
Review Comment:
nit: can we turn `findViolation` to a static method so we don't need the
unwrap here? In another word, can we make `findViolation` independent of
`constraints`? Since it is a workaround that will be removed shortly anyway.
--
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]