Skip to content

DeltaColumnBuilder

DeltaColumnBuilder is a builder interface to create columns programmatically.

DeltaColumnBuilder is created using DeltaTable.columnBuilder utility.

In the end, DeltaColumnBuilder is supposed to be built.

io.delta.tables Package

DeltaColumnBuilder belongs to io.delta.tables package.

import io.delta.tables.DeltaColumnBuilder

Creating Instance

DeltaColumnBuilder takes the following to be created:

Operators

build

build(): StructField

Creates a StructField (Spark SQL)

comment

comment(
  comment: String): DeltaColumnBuilder

dataType

dataType(
  dataType: DataType): DeltaColumnBuilder
dataType(
  dataType: String): DeltaColumnBuilder

generatedAlwaysAs

generatedAlwaysAs(
  expr: String): DeltaColumnBuilder

Registers the Generation Expression of this field

nullable

nullable(
  nullable: Boolean): DeltaColumnBuilder

Generation Expression

generationExpr: Option[String] = None

DeltaColumnBuilder uses generationExpr internal registry for the generatedAlwaysAs expression.

When requested to build a StructField, DeltaColumnBuilder registers generationExpr under delta.generationExpression key in the metadata (of this field).