类 DeltaMergeBuilder
- 所有已实现的接口:
org.apache.spark.internal.Logging
,org.apache.spark.sql.delta.util.AnalysisHelper
- whenMatched
子句
- whenMatched
子句中的条件是可选的。但是,如果存在多个 whenMatched
子句,则只有最后一个可以省略条件。
- 当存在多个 whenMatched
子句并且条件(或缺乏条件)使得某一行满足多个子句时,则执行第一个满足的子句的操作。换句话说,whenMatched
子句的顺序很重要。
- 如果没有 whenMatched
子句与满足合并条件的源-目标行对匹配,则目标行将不会被更新或删除。
- 如果您想使用源 DataFrame 中相应的列更新目标 Delta 表的所有列,那么您可以使用 whenMatched(...).updateAll()
。这等同于
whenMatched(...).updateExpr(Map( ("col1", "source.col1"), ("col2", "source.col2"), ...))
- whenNotMatched
子句
- whenNotMatched
子句中的条件是可选的。但是,如果存在多个 whenNotMatched
子句,则只有最后一个可以省略条件。
- 当存在多个 whenNotMatched
子句并且条件(或缺乏条件)使得某一行满足多个子句时,则执行第一个满足的子句的操作。换句话说,whenNotMatched
子句的顺序很重要。
- 如果没有 whenNotMatched
子句存在,或者存在但未匹配的源行不满足条件,则源行不会被插入。
- 如果您想使用源 DataFrame 中相应的列插入目标 Delta 表的所有列,那么您可以使用 whenNotMatched(...).insertAll()
。这等同于
whenNotMatched(...).insertExpr(Map( ("col1", "source.col1"), ("col2", "source.col2"), ...))
- whenNotMatchedBySource
子句
- whenNotMatchedBySource
子句中的条件是可选的。但是,如果存在多个 whenNotMatchedBySource
子句,则只有最后一个可以省略条件。
- 当存在多个 whenNotMatchedBySource
子句并且条件(或缺乏条件)使得某一行满足多个子句时,则执行第一个满足的子句的操作。换句话说,whenNotMatchedBySource
子句的顺序很重要。
- 如果没有 whenNotMatchedBySource
子句存在,或者存在但未匹配的目标行不满足任何 whenNotMatchedBySource
子句条件,则目标行将不会被更新或删除。
Scala 示例:使用源 DataFrame 中的新键值更新键值 Delta 表
deltaTable
.as("target")
.merge(
source.as("source"),
"target.key = source.key")
.withSchemaEvolution()
.whenMatched()
.updateExpr(Map(
"value" -> "source.value"))
.whenNotMatched()
.insertExpr(Map(
"key" -> "source.key",
"value" -> "source.value"))
.whenNotMatchedBySource()
.updateExpr(Map(
"value" -> "target.value + 1"))
.execute()
Java 示例:使用源 DataFrame 中的新键值更新键值 Delta 表
deltaTable
.as("target")
.merge(
source.as("source"),
"target.key = source.key")
.withSchemaEvolution()
.whenMatched()
.updateExpr(
new HashMap<String, String>() {{
put("value", "source.value");
}})
.whenNotMatched()
.insertExpr(
new HashMap<String, String>() {{
put("key", "source.key");
put("value", "source.value");
}})
.whenNotMatchedBySource()
.updateExpr(
new HashMap<String, String>() {{
put("value", "target.value + 1");
}})
.execute();
- 自
- 0.3.0
-
嵌套类摘要
从接口 org.apache.spark.sql.delta.util.AnalysisHelper 继承的嵌套类/接口
org.apache.spark.sql.delta.util.AnalysisHelper.FakeLogicalPlan, org.apache.spark.sql.delta.util.AnalysisHelper.FakeLogicalPlan$
从接口 org.apache.spark.internal.Logging 继承的嵌套类/接口
org.apache.spark.internal.Logging.LogStringContext, org.apache.spark.internal.Logging.SparkShellLoggingFilter
-
构造器摘要
构造器构造器描述DeltaMergeBuilder
(DeltaTable targetTable, org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> source, org.apache.spark.sql.Column onCondition, scala.collection.immutable.Seq<org.apache.spark.sql.catalyst.plans.logical.DeltaMergeIntoClause> whenClauses) -
方法摘要
修饰符及类型方法描述org.apache.spark.sql.Dataset<org.apache.spark.sql.Row>
execute()
根据构建的匹配和不匹配操作执行合并操作。当合并条件匹配时,构建要执行的操作。whenMatched
(String condition) 当合并条件匹配且给定 `condition` 为 true 时,构建要执行的操作。whenMatched
(org.apache.spark.sql.Column condition) 当合并条件匹配且给定 `condition` 为 true 时,构建要执行的操作。当合并条件不匹配时,构建要执行的操作。whenNotMatched
(String condition) 当合并条件不匹配且给定 `condition` 为 true 时,构建要执行的操作。whenNotMatched
(org.apache.spark.sql.Column condition) 当合并条件不匹配且给定 `condition` 为 true 时,构建要执行的操作。当合并条件不被源匹配时,构建要执行的操作。whenNotMatchedBySource
(String condition) 当合并条件不被源匹配且给定 `condition` 为 true 时,构建要执行的操作。whenNotMatchedBySource
(org.apache.spark.sql.Column condition) 当合并条件不被源匹配且给定 `condition` 为 true 时,构建要执行的操作。启用合并操作的模式演进。从接口 org.apache.spark.sql.delta.util.AnalysisHelper 继承的方法
improveUnsupportedOpError, resolveReferencesForExpressions, toDataset, tryResolveReferences, tryResolveReferencesForExpressions, tryResolveReferencesForExpressions
从接口 org.apache.spark.internal.Logging 继承的方法
initializeForcefully, initializeLogIfNecessary, initializeLogIfNecessary, initializeLogIfNecessary$default$2, isTraceEnabled, log, logDebug, logDebug, logDebug, logDebug, logError, logError, logError, logError, logInfo, logInfo, logInfo, logInfo, logName, LogStringContext, logTrace, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, logWarning, org$apache$spark$internal$Logging$$log_, org$apache$spark$internal$Logging$$log__$eq, withLogContext
-
构造器详细信息
-
DeltaMergeBuilder
public DeltaMergeBuilder(DeltaTable targetTable, org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> source, org.apache.spark.sql.Column onCondition, scala.collection.immutable.Seq<org.apache.spark.sql.catalyst.plans.logical.DeltaMergeIntoClause> whenClauses)
-
-
方法详情
-
whenMatched
构建当合并条件匹配时执行的操作。这会返回DeltaMergeMatchedActionBuilder
对象,该对象可用于指定如何使用源行更新或删除匹配的目标表行。- 返回
- (未记录)
- 自
- 0.3.0
-
whenMatched
构建当合并条件匹配且给定condition
为 true 时执行的操作。这会返回DeltaMergeMatchedActionBuilder
对象,该对象可用于指定如何使用源行更新或删除匹配的目标表行。- 参数
condition
- 作为 SQL 格式字符串的布尔表达式- 返回
- (未记录)
- 自
- 0.3.0
-
whenMatched
构建当合并条件匹配且给定condition
为 true 时执行的操作。这会返回一个DeltaMergeMatchedActionBuilder
对象,该对象可用于指定如何使用源行更新或删除匹配的目标表行。- 参数
condition
- 作为 Column 对象的布尔表达式- 返回
- (未记录)
- 自
- 0.3.0
-
whenNotMatched
构建当合并条件不匹配时执行的操作。这会返回DeltaMergeNotMatchedActionBuilder
对象,该对象可用于指定如何将新的源行插入到目标表中。- 返回
- (未记录)
- 自
- 0.3.0
-
whenNotMatched
构建当合并条件不匹配且给定condition
为 true 时执行的操作。这会返回DeltaMergeMatchedActionBuilder
对象,该对象可用于指定如何将新的源行插入到目标表中。- 参数
condition
- 作为 SQL 格式字符串的布尔表达式- 返回
- (未记录)
- 自
- 0.3.0
-
whenNotMatched
构建当合并条件不匹配且给定condition
为 true 时执行的操作。这会返回DeltaMergeMatchedActionBuilder
对象,该对象可用于指定如何将新的源行插入到目标表中。- 参数
condition
- 作为 Column 对象的布尔表达式- 返回
- (未记录)
- 自
- 0.3.0
-
whenNotMatchedBySource
构建当源不匹配合并条件时执行的操作。这会返回DeltaMergeNotMatchedBySourceActionBuilder
对象,该对象可用于指定如何更新或删除目标表行。- 返回
- (未记录)
- 自
- 2.3.0
-
whenNotMatchedBySource
构建当源不匹配合并条件且给定condition
为 true 时执行的操作。这会返回DeltaMergeNotMatchedBySourceActionBuilder
对象,该对象可用于指定如何更新或删除目标表行。- 参数
condition
- 作为 SQL 格式字符串的布尔表达式- 返回
- (未记录)
- 自
- 2.3.0
-
whenNotMatchedBySource
public DeltaMergeNotMatchedBySourceActionBuilder whenNotMatchedBySource(org.apache.spark.sql.Column condition) 构建当源不匹配合并条件且给定condition
为 true 时执行的操作。这会返回DeltaMergeNotMatchedBySourceActionBuilder
对象,该对象可用于指定如何更新或删除目标表行。- 参数
condition
- 作为 Column 对象的布尔表达式- 返回
- (未记录)
- 自
- 2.3.0
-
withSchemaEvolution
为合并操作启用 schema 演进。这允许根据源表/列的 schema 自动更新目标表/列的 schema。- 返回
- (未记录)
- 自
- 3.2.0
-
execute
public org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> execute()根据构建的匹配和不匹配操作执行合并操作。- 返回
- (未记录)
- 自
- 0.3.0
-