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
- Alphabetic
- By Inheritance
- DeltaTableBuilder
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
addColumn(col: StructField): DeltaTableBuilder
:: Evolving ::
:: Evolving ::
Specify a column.
- col
structField the column struct
- Annotations
- @Evolving()
- Since
1.0.0
-
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
-
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
-
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
-
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
-
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
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
clusterBy(colNames: String*): DeltaTableBuilder
:: Evolving ::
:: Evolving ::
Specify the columns to cluster the output on the file system.
Note: This should only include table columns already defined in schema.
- colNames
string* column names for clustering
- Annotations
- @Evolving() @varargs()
- Since
3.2.0
-
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
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
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
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
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
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
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
-
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
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
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
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()