cloud-fan commented on a change in pull request #23606: [SPARK-26666][SQL] Support DSv2 overwrite and dynamic partition overwrite. URL: https://github.com/apache/spark/pull/23606#discussion_r249638423
########## File path: sql/core/src/main/java/org/apache/spark/sql/sources/v2/writer/SupportsOverwrite.java ########## @@ -0,0 +1,36 @@ +/* + * 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.sources.v2.writer; + +import org.apache.spark.sql.sources.Filter; + +/** + * Write builder trait for tables that support overwrite by filter. + * <p> + * Overwriting data by filter will delete any data that matches the filter and replace it with data + * that is committed in the write. + */ +public interface SupportsOverwrite extends WriteBuilder { Review comment: This reminds me of the SQL MERGE command: https://en.wikipedia.org/wiki/Merge_(SQL) https://docs.microsoft.com/en-us/sql/t-sql/statements/merge-transact-sql?view=sql-server-2017 SQL has 3 standard simple date changing commands: INSERT, UPDATE, DELETE. INSERT is Append in DS v2. UPDATE and DELETE are special. They do not have a source table, they just change the data of the target table directly. I'd say they are not data writing, and we should exclude them from ds v2 write API. MERGE(also called UPSERT) is a more powerful version of INSERT. It uses the source table to update the target table. For each row in the target table, find the matched row in the source table w.r.t. a condition, and update the row in the target table according to the matched row. This `SupportsOverwrite` here looks like just a DELETE + INSERT, and I don't know if there is any SQL command has the same semantic. Can you give some use cases of this overwrite? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org