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

[Spark] Block unsupported operations on identity columns #3457

Conversation

zhipengmao-db
Copy link
Contributor

@zhipengmao-db zhipengmao-db commented Aug 1, 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 block unsupported operations on identity columns including:

  • ALTER TABLE ALTER COLUMN is not supported for IDENTITY columns.
  • Providing values for GENERATED ALWAYS AS IDENTITY column is not supported.
  • PARTITIONED BY IDENTITY column is not supported.
  • ALTER TABLE REPLACE COLUMNS is not supported for table with IDENTITY columns.
  • UPDATE on IDENTITY column is not supported.

How was this patch tested?

A new test suite IdentityColumnAdmissionScalaSuite is added.

Does this PR introduce any user-facing changes?

Yes. The aforementioned operations on identity columns are blocked.

Comment on lines 58 to 63
if (Cast.canUpCast(LongType, targetType)) {
val ex = intercept[DeltaAnalysisException] {
sql(s"ALTER TABLE $tblName $keyword COLUMN id TYPE ${targetType.sql}")
}
assert(ex.getErrorClass === "DELTA_IDENTITY_COLUMNS_ALTER_COLUMN_NOT_SUPPORTED")
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we do a case match on targetType instead of this?

targetType match {
   case IntegerType => // foo
   case DoubleType => // bar
   case _ => fail("unexpected targetType")
}

Copy link
Contributor

@larsk-db larsk-db left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zhipengmao-db zhipengmao-db force-pushed the zhipengmao-db/identity-column-block branch 2 times, most recently from 60feb9d to d519881 Compare August 2, 2024 15:42
@zhipengmao-db zhipengmao-db force-pushed the zhipengmao-db/identity-column-block branch 2 times, most recently from d519881 to 26c363d Compare August 5, 2024 12:54
Copy link
Contributor

@c27kwan c27kwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! :)

@zhipengmao-db zhipengmao-db force-pushed the zhipengmao-db/identity-column-block branch from 26c363d to 3431990 Compare August 7, 2024 08:50
@scottsand-db scottsand-db merged commit e829006 into delta-io:master Aug 7, 2024
10 checks passed
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.

4 participants