cloud-fan commented on code in PR #44119:
URL: https://github.com/apache/spark/pull/44119#discussion_r1428621468
##########
sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala:
##########
@@ -4129,6 +4129,36 @@ class Dataset[T] private[sql](
new DataFrameWriterV2[T](table, this)
}
+ /**
+ * Create a [[DataFrameWriterV2]] for MergeInto action.
+ *
+ * Scala Examples:
+ * {{{
+ * spark.table("source")
+ * .mergeInto("target")
+ * .on($"source.id" === $"target.id")
+ * .whenMatched($"salary" === 100)
+ * .delete()
+ * .whenNotMatched()
+ * .insertAll()
+ * .whenNotMatchedBySource($"salary" === 100)
+ * .update(Map(
+ * "salary" -> lit(200)
+ * ))
+ * .merge()
+ * }}}
+ *
+ * @since 4.0.0
+ */
+ def mergeInto(table: String): DataFrameWriterV2[T] = {
+ if (isStreaming) {
+ logicalPlan.failAnalysis(
+ errorClass = "CALL_ON_STREAMING_DATASET_UNSUPPORTED",
+ messageParameters = Map("methodName" -> toSQLId("mergeInto")))
+ }
+ new DataFrameWriterV2[T](table, this)
Review Comment:
I think it's a good place here to enter the merge API layer, e.g.
`MergeIntoWriter[T]`, similar to `CreateTableWriter[T]`. It's still the
`DataFrameWriterV2` to extend `MergeIntoWriter[T]`, but the exposed APIs become
a subset.
--
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]