aokolnychyi commented on a change in pull request #33008:
URL: https://github.com/apache/spark/pull/33008#discussion_r658352962



##########
File path: 
sql/catalyst/src/main/java/org/apache/spark/sql/connector/write/Merge.java
##########
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.connector.write;
+
+import org.apache.spark.annotation.Experimental;
+import org.apache.spark.sql.connector.expressions.NamedReference;
+import org.apache.spark.sql.connector.read.Scan;
+import org.apache.spark.sql.connector.read.ScanBuilder;
+
+/**
+ * A logical representation of a data source DELETE, UPDATE, or MERGE 
operation that requires
+ * rewriting data.
+ *
+ * @since 3.2.0
+ */
+@Experimental
+public interface Merge {
+
+  /**
+   * The actual SQL operation being performed.
+   */
+  enum Operation {
+    DELETE, UPDATE, MERGE
+  }
+
+  /**
+   * Returns the description associated with this merge.
+   */
+  default String description() {
+    return this.getClass().toString();
+  }
+
+  /**
+   * Returns the actual SQL operation being performed.
+   */
+  Operation operation();
+
+  /**
+   * Returns a {@link ScanBuilder} to configure a {@link Scan} for this merge.
+   * <p>
+   * For sources that support row-level changes, there are no requirements for 
input scans,
+   * but sources that delete by group must be passed a complete replacement of 
groups.
+   * This means that scans must produce all rows in a delete group if any are 
returned.
+   * <p>
+   * For example, if a source can only replace partitions, all rows from a 
partition must
+   * be returned by the scan, even if a filter can narrow the set of changes 
to a single file
+   * in the partition. Similarly, a source that can swap individual files must 
produce all rows
+   * of matching files, not just the rows that may change.
+   */
+  ScanBuilder scanBuilder();

Review comment:
       One of the reasons for introducing `RowLevelOperation` is to have 
coordination between the scan and the write. For example, the write may know 
the scan condition and may check that no data has been added since the scan 
that would match the condition. That is only required under some isolation 
levels. That's why it is up to the source to ensure that.
   
   I'll add a note about this on the next iteration.




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to