Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP][Spark] Python DeltaTableBuilder API for Identity Columns #3044

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

c27kwan
Copy link
Contributor

@c27kwan c27kwan commented May 3, 2024

Which Delta project/connector is this regarding?

  • Spark
  • Standalone
  • Flink
  • Kernel
  • Other (fill in here)

Description

This PR is part of #1959

In this PR, we extend the addColumn interface in DeltaTableBuilder to allow for Identity Columns creation.

Resolves #1072

How was this patch tested?

New tests.

Does this PR introduce any user-facing changes?

We introduce three new parameters to the addColumn method: generatedAlwaysAsIdentity, identityStart, and identityStep, which can be used to specify Identity Columns that are GENERATED BY DEFAULT and GENERATED ALWAYS.

Interface

def addColumn(
        self,
        colName: str,
        dataType: Union[str, DataType],
        nullable: bool = True,
        generatedAlwaysAs: Optional[str] = None,
        generatedAlwaysAsIdentity: Optional[bool] = None,
        identityStart: Optional[int] = None,
        identityStep: Optional[int] = None,
        comment: Optional[str] = None,
) -> "DeltaTableBuilder"

Example Usage

 DeltaTable.create()
    .tableName("tableName")
    .addColumn("id", dataType=LongType(), generatedAlwaysAsIdentity=true, identityStart = 0, identityStep = 1)
    .execute()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for GENERATED ALWAYS AS IDENTITY in DeltaTableBuilder
1 participant