huaxingao commented on code in PR #44119:
URL: https://github.com/apache/spark/pull/44119#discussion_r1427185349
##########
sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala:
##########
@@ -4129,6 +4129,37 @@ 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] = {
+ // TODO: streaming could be adapted to use this interface
Review Comment:
Removed. Thanks
##########
sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala:
##########
@@ -4129,6 +4129,37 @@ class Dataset[T] private[sql](
new DataFrameWriterV2[T](table, this)
}
+ /**
+ * Create a [[DataFrameWriterV2]] for mergeInto action.
Review Comment:
Fixed. Thanks
##########
sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriterV2.scala:
##########
@@ -343,3 +572,84 @@ trait CreateTableWriter[T] extends
WriteConfigMethods[CreateTableWriter[T]] {
*/
def tableProperty(property: String, value: String): CreateTableWriter[T]
}
+
+case class WhenMatched[T] (dfWriter: DataFrameWriterV2[T], condition:
Option[Expression]) {
Review Comment:
Class docs are added. Thanks
--
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]