类 DeltaMergeBuilder 扩展 AnalysisHelper 并包含 Logging
构建器,用于指定如何将源 DataFrame 中的数据合并到目标 Delta 表中。您可以指定任意数量的 `whenMatched` 和 `whenNotMatched` 子句。以下是这些子句的约束。
- `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` 子句,或者存在但未匹配的源行不满足条件,则源行不会被插入。
- 如果要将目标 Delta 表的所有列插入源 DataFrame 的相应列,则可以使用 `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
- 按字母顺序
- 按继承顺序
- DeltaMergeBuilder
- Logging
- AnalysisHelper
- AnyRef
- Any
- 隐藏所有
- 显示所有
- 公共
- 受保护的
实例构造函数
- 新建 DeltaMergeBuilder(targetTable: DeltaTable, source: DataFrame, onCondition: Column, whenClauses: Seq[DeltaMergeIntoClause])
类型成员
- 隐式 类 LogStringContext 扩展 AnyRef
- 定义类
- Logging
值成员
- final def !=(arg0: Any): Boolean
- 定义类
- AnyRef → Any
- final def ##: Int
- 定义类
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- 定义类
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- 定义类
- Any
- def clone(): AnyRef
- 属性
- protected[lang]
- 定义类
- AnyRef
- 注解
- @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
- final def eq(arg0: AnyRef): Boolean
- 定义类
- AnyRef
- def equals(arg0: AnyRef): Boolean
- 定义类
- AnyRef → Any
- def execute(): DataFrame
根据构建的匹配和不匹配操作执行合并操作。
根据构建的匹配和不匹配操作执行合并操作。
- 自
0.3.0
- final def getClass(): Class[_ <: AnyRef]
- 定义类
- AnyRef → Any
- 注解
- @IntrinsicCandidate() @native()
- def hashCode(): Int
- 定义类
- AnyRef → Any
- 注解
- @IntrinsicCandidate() @native()
- def improveUnsupportedOpError[T](f: => T): T
- 属性
- 受保护
- 定义类
- AnalysisHelper
- def initializeLogIfNecessary(isInterpreter: Boolean, silent: Boolean): Boolean
- 属性
- 受保护
- 定义类
- Logging
- def initializeLogIfNecessary(isInterpreter: Boolean): Unit
- 属性
- 受保护
- 定义类
- Logging
- final def isInstanceOf[T0]: Boolean
- 定义类
- Any
- def isTraceEnabled(): Boolean
- 属性
- 受保护
- 定义类
- Logging
- def log: Logger
- 属性
- 受保护
- 定义类
- Logging
- def logDebug(msg: => String, throwable: Throwable): Unit
- 属性
- 受保护
- 定义类
- Logging
- def logDebug(entry: LogEntry, throwable: Throwable): Unit
- 属性
- 受保护
- 定义类
- Logging
- def logDebug(entry: LogEntry): Unit
- 属性
- 受保护
- 定义类
- Logging
- def logDebug(msg: => String): Unit
- 属性
- 受保护
- 定义类
- Logging
- def logError(msg: => String, throwable: Throwable): Unit
- 属性
- 受保护
- 定义类
- Logging
- def logError(entry: LogEntry, throwable: Throwable): Unit
- 属性
- 受保护
- 定义类
- Logging
- def logError(entry: LogEntry): Unit
- 属性
- 受保护
- 定义类
- Logging
- def logError(msg: => String): Unit
- 属性
- 受保护
- 定义类
- Logging
- def logInfo(msg: => String, throwable: Throwable): Unit
- 属性
- 受保护
- 定义类
- Logging
- def logInfo(entry: LogEntry, throwable: Throwable): Unit
- 属性
- 受保护
- 定义类
- Logging
- def logInfo(entry: LogEntry): Unit
- 属性
- 受保护
- 定义类
- Logging
- def logInfo(msg: => String): Unit
- 属性
- 受保护
- 定义类
- Logging
- def logName: String
- 属性
- 受保护
- 定义类
- Logging
- def logTrace(msg: => String, throwable: Throwable): Unit
- 属性
- 受保护
- 定义类
- Logging
- def logTrace(entry: LogEntry, throwable: Throwable): Unit
- 属性
- 受保护
- 定义类
- Logging
- def logTrace(entry: LogEntry): Unit
- 属性
- 受保护
- 定义类
- Logging
- def logTrace(msg: => String): Unit
- 属性
- 受保护
- 定义类
- Logging
- def logWarning(msg: => String, throwable: Throwable): Unit
- 属性
- 受保护
- 定义类
- Logging
- def logWarning(entry: LogEntry, throwable: Throwable): Unit
- 属性
- 受保护
- 定义类
- Logging
- def logWarning(entry: LogEntry): Unit
- 属性
- 受保护
- 定义类
- Logging
- def logWarning(msg: => String): Unit
- 属性
- 受保护
- 定义类
- Logging
- final def ne(arg0: AnyRef): Boolean
- 定义类
- AnyRef
- final def notify(): Unit
- 定义类
- AnyRef
- 注解
- @IntrinsicCandidate() @native()
- final def notifyAll(): Unit
- 定义类
- AnyRef
- 注解
- @IntrinsicCandidate() @native()
- def resolveReferencesForExpressions(sparkSession: SparkSession, exprs: Seq[Expression], planProvidingAttrs: LogicalPlan): Seq[Expression]
- 属性
- 受保护
- 定义类
- AnalysisHelper
- final def synchronized[T0](arg0: => T0): T0
- 定义类
- AnyRef
- def toDataset(sparkSession: SparkSession, logicalPlan: LogicalPlan): Dataset[Row]
- 属性
- 受保护
- 定义类
- AnalysisHelper
- def toString(): String
- 定义类
- AnyRef → Any
- def tryResolveReferences(sparkSession: SparkSession)(expr: Expression, planContainingExpr: LogicalPlan): Expression
- 属性
- 受保护
- 定义类
- AnalysisHelper
- def tryResolveReferencesForExpressions(sparkSession: SparkSession)(exprs: Seq[Expression], plansProvidingAttrs: Seq[LogicalPlan]): Seq[Expression]
- 属性
- 受保护
- 定义类
- AnalysisHelper
- def tryResolveReferencesForExpressions(sparkSession: SparkSession, exprs: Seq[Expression], planContainingExpr: LogicalPlan): Seq[Expression]
- 属性
- 受保护
- 定义类
- AnalysisHelper
- final def wait(arg0: Long, arg1: Int): Unit
- 定义类
- AnyRef
- 注解
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- 定义类
- AnyRef
- 注解
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- 定义类
- AnyRef
- 注解
- @throws(classOf[java.lang.InterruptedException])
- def whenMatched(condition: Column): DeltaMergeMatchedActionBuilder
当合并条件匹配且给定 `condition` 为 true 时,构建要执行的操作。
当合并条件匹配且给定 `condition` 为 true 时,构建要执行的操作。这将返回一个 DeltaMergeMatchedActionBuilder 对象,可用于指定如何使用源行更新或删除匹配的目标表行。
- 条件
作为 Column 对象的布尔表达式
- 自
0.3.0
- def whenMatched(condition: String): DeltaMergeMatchedActionBuilder
当合并条件匹配且给定 `condition` 为 true 时,构建要执行的操作。
当合并条件匹配且给定 `condition` 为 true 时,构建要执行的操作。这将返回一个 DeltaMergeMatchedActionBuilder 对象,可用于指定如何使用源行更新或删除匹配的目标表行。
- 条件
作为 SQL 格式字符串的布尔表达式
- 自
0.3.0
- def whenMatched(): DeltaMergeMatchedActionBuilder
当合并条件匹配时,构建要执行的操作。
当合并条件匹配时,构建要执行的操作。这将返回一个 DeltaMergeMatchedActionBuilder 对象,可用于指定如何使用源行更新或删除匹配的目标表行。
- 自
0.3.0
- def whenNotMatched(condition: Column): DeltaMergeNotMatchedActionBuilder
当合并条件不匹配且给定 `condition` 为 true 时,构建要执行的操作。
当合并条件不匹配且给定 `condition` 为 true 时,构建要执行的操作。这将返回一个 DeltaMergeMatchedActionBuilder 对象,可用于指定如何将新源行插入目标表。
- 条件
作为 Column 对象的布尔表达式
- 自
0.3.0
- def whenNotMatched(condition: String): DeltaMergeNotMatchedActionBuilder
当合并条件不匹配且给定 `condition` 为 true 时,构建要执行的操作。
当合并条件不匹配且给定 `condition` 为 true 时,构建要执行的操作。这将返回一个 DeltaMergeMatchedActionBuilder 对象,可用于指定如何将新源行插入目标表。
- 条件
作为 SQL 格式字符串的布尔表达式
- 自
0.3.0
- def whenNotMatched(): DeltaMergeNotMatchedActionBuilder
当合并条件不匹配时,构建要执行的操作。
当合并条件不匹配时,构建要执行的操作。这将返回一个 DeltaMergeNotMatchedActionBuilder 对象,可用于指定如何将新源行插入目标表。
- 自
0.3.0
- def whenNotMatchedBySource(condition: Column): DeltaMergeNotMatchedBySourceActionBuilder
当合并条件不被源匹配且给定 `condition` 为 true 时,构建要执行的操作。
当合并条件不被源匹配且给定 `condition` 为 true 时,构建要执行的操作。这将返回一个 DeltaMergeNotMatchedBySourceActionBuilder 对象,可用于指定如何更新或删除目标表行。
- 条件
作为 Column 对象的布尔表达式
- 自
2.3.0
- def whenNotMatchedBySource(condition: String): DeltaMergeNotMatchedBySourceActionBuilder
当合并条件不被源匹配且给定 `condition` 为 true 时,构建要执行的操作。
当合并条件不被源匹配且给定 `condition` 为 true 时,构建要执行的操作。这将返回一个 DeltaMergeNotMatchedBySourceActionBuilder 对象,可用于指定如何更新或删除目标表行。
- 条件
作为 SQL 格式字符串的布尔表达式
- 自
2.3.0
- def whenNotMatchedBySource(): DeltaMergeNotMatchedBySourceActionBuilder
当合并条件不被源匹配时,构建要执行的操作。
当合并条件不被源匹配时,构建要执行的操作。这将返回一个 DeltaMergeNotMatchedBySourceActionBuilder 对象,可用于指定如何更新或删除目标表行。
- 自
2.3.0
- def withLogContext(context: Map[String, String])(body: => Unit): Unit
- 属性
- 受保护
- 定义类
- Logging
- def withSchemaEvolution(): DeltaMergeBuilder
启用合并操作的模式演进。
启用合并操作的模式演进。这允许目标表/列的模式根据源表/列的模式自动更新。
- 自
3.2.0
已弃用的值成员
- def finalize(): Unit
- 属性
- protected[lang]
- 定义类
- AnyRef
- 注解
- @throws(classOf[java.lang.Throwable]) @Deprecated
- 已弃用
(版本 9 起)