Packages

c

io.delta.tables

DeltaTableBuilder

class DeltaTableBuilder extends AnyRef

:: Evolving ::

Builder to specify how to create / replace a Delta table. You must specify the table name or the path before executing the builder. You can specify the table columns, the partitioning columns, the location of the data, the table comment and the property, and how you want to create / replace the Delta table.

After executing the builder, an instance of DeltaTable is returned.

Scala example to create a Delta table with generated columns, using the table name:

val table: DeltaTable = DeltaTable.create()
  .tableName("testTable")
  .addColumn("c1",  dataType = "INT", nullable = false)
  .addColumn(
    DeltaTable.columnBuilder("c2")
      .dataType("INT")
      .generatedAlwaysAs("c1 + 10")
      .build()
  )
  .addColumn(
    DeltaTable.columnBuilder("c3")
      .dataType("INT")
      .comment("comment")
      .nullable(true)
      .build()
  )
  .partitionedBy("c1", "c2")
  .execute()

Scala example to create a delta table using the location:

val table: DeltaTable = DeltaTable.createIfNotExists(spark)
  .location("/foo/`bar`")
  .addColumn("c1", dataType = "INT", nullable = false)
  .addColumn(
    DeltaTable.columnBuilder(spark, "c2")
      .dataType("INT")
      .generatedAlwaysAs("c1 + 10")
      .build()
  )
  .addColumn(
    DeltaTable.columnBuilder(spark, "c3")
      .dataType("INT")
      .comment("comment")
      .nullable(true)
      .build()
  )
  .partitionedBy("c1", "c2")
  .execute()

Java Example to replace a table:

DeltaTable table = DeltaTable.replace()
  .tableName("db.table")
  .addColumn("c1",  "INT", false)
  .addColumn(
    DeltaTable.columnBuilder("c2")
      .dataType("INT")
      .generatedAlwaysBy("c1 + 10")
      .build()
  )
  .execute();
Annotations
@Evolving()
Since

1.0.0

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. DeltaTableBuilder
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def addColumn(col: StructField): DeltaTableBuilder

    :: Evolving ::

    :: Evolving ::

    Specify a column.

    col

    structField the column struct

    Annotations
    @Evolving()
    Since

    1.0.0

  5. def addColumn(colName: String, dataType: DataType, nullable: Boolean): DeltaTableBuilder

    :: Evolving ::

    :: Evolving ::

    Specify a column.

    colName

    string the column name

    dataType

    dataType the DDL data type

    nullable

    boolean whether the column is nullable

    Annotations
    @Evolving()
    Since

    1.0.0

  6. def addColumn(colName: String, dataType: String, nullable: Boolean): DeltaTableBuilder

    :: Evolving ::

    :: Evolving ::

    Specify a column.

    colName

    string the column name

    dataType

    string the DDL data type

    nullable

    boolean whether the column is nullable

    Annotations
    @Evolving()
    Since

    1.0.0

  7. def addColumn(colName: String, dataType: DataType): DeltaTableBuilder

    :: Evolving ::

    :: Evolving ::

    Specify a column.

    colName

    string the column name

    dataType

    dataType the DDL data type

    Annotations
    @Evolving()
    Since

    1.0.0

  8. def addColumn(colName: String, dataType: String): DeltaTableBuilder

    :: Evolving ::

    :: Evolving ::

    Specify a column.

    colName

    string the column name

    dataType

    string the DDL data type

    Annotations
    @Evolving()
    Since

    1.0.0

  9. def addColumns(cols: StructType): DeltaTableBuilder

    :: Evolving ::

    :: Evolving ::

    Specify columns with an existing schema.

    cols

    structType the existing schema for columns

    Annotations
    @Evolving()
    Since

    1.0.0

  10. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  11. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  12. def comment(comment: String): DeltaTableBuilder

    :: Evolving ::

    :: Evolving ::

    Specify the table comment to describe the table.

    comment

    string table comment

    Annotations
    @Evolving()
    Since

    1.0.0

  13. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  15. def execute(): DeltaTable

    :: Evolving ::

    :: Evolving ::

    Execute the command to create / replace a Delta table and returns a instance of DeltaTable.

    Annotations
    @Evolving()
    Since

    1.0.0

  16. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  17. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  18. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  19. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  20. def location(location: String): DeltaTableBuilder

    :: Evolving ::

    :: Evolving ::

    Specify the path to the directory where table data is stored, which could be a path on distributed storage.

    location

    string the data location

    Annotations
    @Evolving()
    Since

    1.0.0

  21. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  22. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  23. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  24. def partitionedBy(colNames: String*): DeltaTableBuilder

    :: Evolving ::

    :: Evolving ::

    Specify the columns to partition the output on the file system.

    Note: This should only include table columns already defined in schema.

    colNames

    string* column names for partitioning

    Annotations
    @Evolving() @varargs()
    Since

    1.0.0

  25. def property(key: String, value: String): DeltaTableBuilder

    :: Evolving ::

    :: Evolving ::

    Specify a key-value pair to tag the table definition.

    key

    string the table property key

    value

    string the table property value

    Annotations
    @Evolving()
    Since

    1.0.0

  26. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  27. def tableName(identifier: String): DeltaTableBuilder

    :: Evolving ::

    :: Evolving ::

    Specify the table name, optionally qualified with a database name [database_name.] table_name

    identifier

    string the table name

    Annotations
    @Evolving()
    Since

    1.0.0

  28. def toString(): String
    Definition Classes
    AnyRef → Any
  29. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  30. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped