You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/11/16 17:34:06 UTC

[GitHub] [spark] cloud-fan commented on a diff in pull request #38005: [SPARK-40550][SQL] DataSource V2: Handle DELETE commands for delta-based sources

cloud-fan commented on code in PR #38005:
URL: https://github.com/apache/spark/pull/38005#discussion_r1024306166


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/RewriteRowLevelCommand.scala:
##########
@@ -68,4 +73,58 @@ trait RewriteRowLevelCommand extends Rule[LogicalPlan] {
       operation.requiredMetadataAttributes,
       relation)
   }
+
+  protected def resolveRowIdAttrs(
+      relation: DataSourceV2Relation,
+      operation: RowLevelOperation): Seq[AttributeReference] = {
+
+    operation match {
+      case supportsDelta: SupportsDelta =>
+        val rowIdAttrs = V2ExpressionUtils.resolveRefs[AttributeReference](
+          supportsDelta.rowId,
+          relation)
+
+        val nullableRowIdAttrs = rowIdAttrs.filter(_.nullable)
+        if (nullableRowIdAttrs.nonEmpty) {
+          throw QueryCompilationErrors.nullableRowIdError(nullableRowIdAttrs)
+        }
+
+        rowIdAttrs
+
+      case _ =>
+        throw QueryCompilationErrors.notDeltaBasedRowLevelOperationError(operation)

Review Comment:
   this should never happen, we can throw `SparkException.internalError` directly.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org