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

线性超类型
Logging, AnalysisHelper, AnyRef, Any
排序
  1. 按字母顺序
  2. 按继承顺序
继承
  1. DeltaMergeBuilder
  2. Logging
  3. AnalysisHelper
  4. AnyRef
  5. Any
  1. 隐藏所有
  2. 显示所有
可见性
  1. 公共
  2. 受保护的

实例构造函数

  1. 新建 DeltaMergeBuilder(targetTable: DeltaTable, source: DataFrame, onCondition: Column, whenClauses: Seq[DeltaMergeIntoClause])

类型成员

  1. 隐式 LogStringContext 扩展 AnyRef
    定义类
    Logging

值成员

  1. final def !=(arg0: Any): Boolean
    定义类
    AnyRef → Any
  2. final def ##: Int
    定义类
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    定义类
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    定义类
    Any
  5. def clone(): AnyRef
    属性
    protected[lang]
    定义类
    AnyRef
    注解
    @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
  6. final def eq(arg0: AnyRef): Boolean
    定义类
    AnyRef
  7. def equals(arg0: AnyRef): Boolean
    定义类
    AnyRef → Any
  8. def execute(): DataFrame

    根据构建的匹配和不匹配操作执行合并操作。

    根据构建的匹配和不匹配操作执行合并操作。

    0.3.0

  9. final def getClass(): Class[_ <: AnyRef]
    定义类
    AnyRef → Any
    注解
    @IntrinsicCandidate() @native()
  10. def hashCode(): Int
    定义类
    AnyRef → Any
    注解
    @IntrinsicCandidate() @native()
  11. def improveUnsupportedOpError[T](f: => T): T
    属性
    受保护
    定义类
    AnalysisHelper
  12. def initializeLogIfNecessary(isInterpreter: Boolean, silent: Boolean): Boolean
    属性
    受保护
    定义类
    Logging
  13. def initializeLogIfNecessary(isInterpreter: Boolean): Unit
    属性
    受保护
    定义类
    Logging
  14. final def isInstanceOf[T0]: Boolean
    定义类
    Any
  15. def isTraceEnabled(): Boolean
    属性
    受保护
    定义类
    Logging
  16. def log: Logger
    属性
    受保护
    定义类
    Logging
  17. def logDebug(msg: => String, throwable: Throwable): Unit
    属性
    受保护
    定义类
    Logging
  18. def logDebug(entry: LogEntry, throwable: Throwable): Unit
    属性
    受保护
    定义类
    Logging
  19. def logDebug(entry: LogEntry): Unit
    属性
    受保护
    定义类
    Logging
  20. def logDebug(msg: => String): Unit
    属性
    受保护
    定义类
    Logging
  21. def logError(msg: => String, throwable: Throwable): Unit
    属性
    受保护
    定义类
    Logging
  22. def logError(entry: LogEntry, throwable: Throwable): Unit
    属性
    受保护
    定义类
    Logging
  23. def logError(entry: LogEntry): Unit
    属性
    受保护
    定义类
    Logging
  24. def logError(msg: => String): Unit
    属性
    受保护
    定义类
    Logging
  25. def logInfo(msg: => String, throwable: Throwable): Unit
    属性
    受保护
    定义类
    Logging
  26. def logInfo(entry: LogEntry, throwable: Throwable): Unit
    属性
    受保护
    定义类
    Logging
  27. def logInfo(entry: LogEntry): Unit
    属性
    受保护
    定义类
    Logging
  28. def logInfo(msg: => String): Unit
    属性
    受保护
    定义类
    Logging
  29. def logName: String
    属性
    受保护
    定义类
    Logging
  30. def logTrace(msg: => String, throwable: Throwable): Unit
    属性
    受保护
    定义类
    Logging
  31. def logTrace(entry: LogEntry, throwable: Throwable): Unit
    属性
    受保护
    定义类
    Logging
  32. def logTrace(entry: LogEntry): Unit
    属性
    受保护
    定义类
    Logging
  33. def logTrace(msg: => String): Unit
    属性
    受保护
    定义类
    Logging
  34. def logWarning(msg: => String, throwable: Throwable): Unit
    属性
    受保护
    定义类
    Logging
  35. def logWarning(entry: LogEntry, throwable: Throwable): Unit
    属性
    受保护
    定义类
    Logging
  36. def logWarning(entry: LogEntry): Unit
    属性
    受保护
    定义类
    Logging
  37. def logWarning(msg: => String): Unit
    属性
    受保护
    定义类
    Logging
  38. final def ne(arg0: AnyRef): Boolean
    定义类
    AnyRef
  39. final def notify(): Unit
    定义类
    AnyRef
    注解
    @IntrinsicCandidate() @native()
  40. final def notifyAll(): Unit
    定义类
    AnyRef
    注解
    @IntrinsicCandidate() @native()
  41. def resolveReferencesForExpressions(sparkSession: SparkSession, exprs: Seq[Expression], planProvidingAttrs: LogicalPlan): Seq[Expression]
    属性
    受保护
    定义类
    AnalysisHelper
  42. final def synchronized[T0](arg0: => T0): T0
    定义类
    AnyRef
  43. def toDataset(sparkSession: SparkSession, logicalPlan: LogicalPlan): Dataset[Row]
    属性
    受保护
    定义类
    AnalysisHelper
  44. def toString(): String
    定义类
    AnyRef → Any
  45. def tryResolveReferences(sparkSession: SparkSession)(expr: Expression, planContainingExpr: LogicalPlan): Expression
    属性
    受保护
    定义类
    AnalysisHelper
  46. def tryResolveReferencesForExpressions(sparkSession: SparkSession)(exprs: Seq[Expression], plansProvidingAttrs: Seq[LogicalPlan]): Seq[Expression]
    属性
    受保护
    定义类
    AnalysisHelper
  47. def tryResolveReferencesForExpressions(sparkSession: SparkSession, exprs: Seq[Expression], planContainingExpr: LogicalPlan): Seq[Expression]
    属性
    受保护
    定义类
    AnalysisHelper
  48. final def wait(arg0: Long, arg1: Int): Unit
    定义类
    AnyRef
    注解
    @throws(classOf[java.lang.InterruptedException])
  49. final def wait(arg0: Long): Unit
    定义类
    AnyRef
    注解
    @throws(classOf[java.lang.InterruptedException]) @native()
  50. final def wait(): Unit
    定义类
    AnyRef
    注解
    @throws(classOf[java.lang.InterruptedException])
  51. def whenMatched(condition: Column): DeltaMergeMatchedActionBuilder

    当合并条件匹配且给定 `condition` 为 true 时,构建要执行的操作。

    当合并条件匹配且给定 `condition` 为 true 时,构建要执行的操作。这将返回一个 DeltaMergeMatchedActionBuilder 对象,可用于指定如何使用源行更新或删除匹配的目标表行。

    条件

    作为 Column 对象的布尔表达式

    0.3.0

  52. def whenMatched(condition: String): DeltaMergeMatchedActionBuilder

    当合并条件匹配且给定 `condition` 为 true 时,构建要执行的操作。

    当合并条件匹配且给定 `condition` 为 true 时,构建要执行的操作。这将返回一个 DeltaMergeMatchedActionBuilder 对象,可用于指定如何使用源行更新或删除匹配的目标表行。

    条件

    作为 SQL 格式字符串的布尔表达式

    0.3.0

  53. def whenMatched(): DeltaMergeMatchedActionBuilder

    当合并条件匹配时,构建要执行的操作。

    当合并条件匹配时,构建要执行的操作。这将返回一个 DeltaMergeMatchedActionBuilder 对象,可用于指定如何使用源行更新或删除匹配的目标表行。

    0.3.0

  54. def whenNotMatched(condition: Column): DeltaMergeNotMatchedActionBuilder

    当合并条件不匹配且给定 `condition` 为 true 时,构建要执行的操作。

    当合并条件不匹配且给定 `condition` 为 true 时,构建要执行的操作。这将返回一个 DeltaMergeMatchedActionBuilder 对象,可用于指定如何将新源行插入目标表。

    条件

    作为 Column 对象的布尔表达式

    0.3.0

  55. def whenNotMatched(condition: String): DeltaMergeNotMatchedActionBuilder

    当合并条件不匹配且给定 `condition` 为 true 时,构建要执行的操作。

    当合并条件不匹配且给定 `condition` 为 true 时,构建要执行的操作。这将返回一个 DeltaMergeMatchedActionBuilder 对象,可用于指定如何将新源行插入目标表。

    条件

    作为 SQL 格式字符串的布尔表达式

    0.3.0

  56. def whenNotMatched(): DeltaMergeNotMatchedActionBuilder

    当合并条件不匹配时,构建要执行的操作。

    当合并条件不匹配时,构建要执行的操作。这将返回一个 DeltaMergeNotMatchedActionBuilder 对象,可用于指定如何将新源行插入目标表。

    0.3.0

  57. def whenNotMatchedBySource(condition: Column): DeltaMergeNotMatchedBySourceActionBuilder

    当合并条件不被源匹配且给定 `condition` 为 true 时,构建要执行的操作。

    当合并条件不被源匹配且给定 `condition` 为 true 时,构建要执行的操作。这将返回一个 DeltaMergeNotMatchedBySourceActionBuilder 对象,可用于指定如何更新或删除目标表行。

    条件

    作为 Column 对象的布尔表达式

    2.3.0

  58. def whenNotMatchedBySource(condition: String): DeltaMergeNotMatchedBySourceActionBuilder

    当合并条件不被源匹配且给定 `condition` 为 true 时,构建要执行的操作。

    当合并条件不被源匹配且给定 `condition` 为 true 时,构建要执行的操作。这将返回一个 DeltaMergeNotMatchedBySourceActionBuilder 对象,可用于指定如何更新或删除目标表行。

    条件

    作为 SQL 格式字符串的布尔表达式

    2.3.0

  59. def whenNotMatchedBySource(): DeltaMergeNotMatchedBySourceActionBuilder

    当合并条件不被源匹配时,构建要执行的操作。

    当合并条件不被源匹配时,构建要执行的操作。这将返回一个 DeltaMergeNotMatchedBySourceActionBuilder 对象,可用于指定如何更新或删除目标表行。

    2.3.0

  60. def withLogContext(context: Map[String, String])(body: => Unit): Unit
    属性
    受保护
    定义类
    Logging
  61. def withSchemaEvolution(): DeltaMergeBuilder

    启用合并操作的模式演进。

    启用合并操作的模式演进。这允许目标表/列的模式根据源表/列的模式自动更新。

    3.2.0

已弃用的值成员

  1. def finalize(): Unit
    属性
    protected[lang]
    定义类
    AnyRef
    注解
    @throws(classOf[java.lang.Throwable]) @Deprecated
    已弃用

    (版本 9 起)

继承自 Logging

继承自 AnalysisHelper

继承自 AnyRef

继承自 Any

未分组