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

Disallow adding not null column when Delta Lake table is not empty #13785

Merged
merged 1 commit into from Aug 23, 2022

Conversation

ebyhr
Copy link
Member

@ebyhr ebyhr commented Aug 23, 2022

Description

Relates to #13587

Documentation

(x) No documentation is needed.

Release notes

(x) Release notes entries required with the following suggested text:

# Delta Lake
* Disallow adding a `NOT NULL` column when the table is not empty. ({issue}`13785`)

@cla-bot cla-bot bot added the cla-signed label Aug 23, 2022
@ebyhr
Copy link
Member Author

ebyhr commented Aug 23, 2022

Read timed out happened. I hope #13746 fixes the issue.

Error:    TestDeltaLakeCreateTableStatisticsLegacyWriter>AbstractTestDeltaLakeCreateTableStatistics.testComplexDataTypes:105->AbstractTestDeltaLakeCreateTableStatistics.access$000:74->AbstractTestQueryFramework.computeActual:217 » QueryFailed
Error:    TestDeltaLakePreferredPartitioning.testPreferredWritePartitioningCreateTable:64->AbstractTestQueryFramework.assertUpdate:323 » QueryFailed

@electrum
Copy link
Member

The release note seems to be backwards?

@ebyhr
Copy link
Member Author

ebyhr commented Aug 23, 2022

@electrum Thanks, fixed.

@@ -1153,7 +1153,7 @@ public void addColumn(ConnectorSession session, ConnectorTableHandle tableHandle
columnsBuilder.build(),
partitionColumns,
columnComments.buildOrThrow(),
columnNullability.buildOrThrow(),
columnsNullability.buildOrThrow(),
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this be a separate commit ?

Copy link
Member

Choose a reason for hiding this comment

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

I think it's related: we allow adding NOT NULL for empty tables
(previously it was ignored)

i think it;s fine to keep as one commit

@@ -1116,6 +1116,10 @@ public void addColumn(ConnectorSession session, ConnectorTableHandle tableHandle
DeltaLakeTableHandle handle = (DeltaLakeTableHandle) tableHandle;
checkSupportedWriterVersion(session, handle.getSchemaTableName());

if (!newColumnMetadata.isNullable() && !metastore.getValidDataFiles(handle.getSchemaTableName(), session).isEmpty()) {
throw new TrinoException(DELTA_LAKE_BAD_WRITE, format("Unable to add NOT NULL column '%s' for non empty table: %s.%s", newColumnMetadata.getName(), handle.getSchemaName(), handle.getTableName()));
Copy link
Member

Choose a reason for hiding this comment

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

IMO "non-empty" should be with a hyphen

@@ -1153,7 +1153,7 @@ public void addColumn(ConnectorSession session, ConnectorTableHandle tableHandle
columnsBuilder.build(),
partitionColumns,
columnComments.buildOrThrow(),
columnNullability.buildOrThrow(),
columnsNullability.buildOrThrow(),
Copy link
Member

Choose a reason for hiding this comment

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

I think it's related: we allow adding NOT NULL for empty tables
(previously it was ignored)

i think it;s fine to keep as one commit

Additionally, stores the correct nullability when adding a new column.
It was always nullable before this change.
@ebyhr ebyhr force-pushed the ebi/delta-add-not-null-column branch from 26cf070 to 563391b Compare August 23, 2022 09:55
@ebyhr ebyhr merged commit 12b0c3d into trinodb:master Aug 23, 2022
@ebyhr ebyhr deleted the ebi/delta-add-not-null-column branch August 23, 2022 13:16
@ebyhr ebyhr mentioned this pull request Aug 23, 2022
@github-actions github-actions bot added this to the 394 milestone Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

5 participants