Skip to content

DeltaTableBuilder

DeltaTableBuilder is a builder interface to create DeltaTables programmatically.

DeltaTableBuilder is created using the following DeltaTable utilities:

In the end, DeltaTableBuilder is supposed to be executed to take action.

io.delta.tables Package

DeltaTableBuilder belongs to io.delta.tables package.

import io.delta.tables.DeltaTableBuilder

Creating Instance

DeltaTableBuilder takes the following to be created:

  • SparkSession (Spark SQL)
  • DeltaTableBuilderOptions

Operators

addColumn

addColumn(
  colName: String,
  dataType: DataType): DeltaTableBuilder
addColumn(
  colName: String,
  dataType: DataType,
  nullable: Boolean): DeltaTableBuilder
addColumn(
  colName: String,
  dataType: String): DeltaTableBuilder
addColumn(
  colName: String,
  dataType: String,
  nullable: Boolean): DeltaTableBuilder
addColumn(
  col: StructField): DeltaTableBuilder

Adds a column (that could be defined using DeltaColumnBuilder)

addColumns

addColumns(
  cols: StructType): DeltaTableBuilder

Adds columns based on the given StructType (Spark SQL)

comment

comment(
  comment: String): DeltaTableBuilder

execute

execute(): DeltaTable

Creates a DeltaTable

location

location(
  location: String): DeltaTableBuilder

partitionedBy

partitionedBy(
  colNames: String*): DeltaTableBuilder

property

property(
  key: String,
  value: String): DeltaTableBuilder

tableName

tableName(
  identifier: String): DeltaTableBuilder