-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Avoid no-op Iceberg table snapshot if DML doesn't change table state #12412
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -565,6 +565,14 @@ public ConnectorOutputTableHandle beginCreateTable(ConnectorSession session, Con | |
| @Override | ||
| public Optional<ConnectorOutputMetadata> finishCreateTable(ConnectorSession session, ConnectorOutputTableHandle tableHandle, Collection<Slice> fragments, Collection<ComputedStatistics> computedStatistics) | ||
| { | ||
| if (fragments.isEmpty()) { | ||
| // Commit the transaction if the table is being created without data | ||
| transaction.newFastAppend().commit(); | ||
| transaction.commitTransaction(); | ||
| transaction = null; | ||
| return Optional.empty(); | ||
| } | ||
|
|
||
| return finishInsert(session, (IcebergWritableTableHandle) tableHandle, fragments, computedStatistics); | ||
| } | ||
|
|
||
|
|
@@ -626,13 +634,17 @@ public ConnectorInsertTableHandle beginInsert(ConnectorSession session, Connecto | |
| @Override | ||
| public Optional<ConnectorOutputMetadata> finishInsert(ConnectorSession session, ConnectorInsertTableHandle insertHandle, Collection<Slice> fragments, Collection<ComputedStatistics> computedStatistics) | ||
| { | ||
| IcebergWritableTableHandle table = (IcebergWritableTableHandle) insertHandle; | ||
| Table icebergTable = transaction.table(); | ||
|
|
||
| List<CommitTaskData> commitTasks = fragments.stream() | ||
| .map(slice -> commitTaskCodec.fromJson(slice.getBytes())) | ||
| .collect(toImmutableList()); | ||
|
|
||
| if (commitTasks.isEmpty()) { | ||
|
||
| transaction = null; | ||
| return Optional.empty(); | ||
| } | ||
|
|
||
| IcebergWritableTableHandle table = (IcebergWritableTableHandle) insertHandle; | ||
| Table icebergTable = transaction.table(); | ||
| Type[] partitionColumnTypes = icebergTable.spec().fields().stream() | ||
| .map(field -> field.transform().getResultType( | ||
| icebergTable.schema().findType(field.sourceId()))) | ||
|
|
@@ -1345,6 +1357,12 @@ private void finishWrite(ConnectorSession session, IcebergTableHandle table, Col | |
| .map(slice -> commitTaskCodec.fromJson(slice.getBytes())) | ||
| .collect(toImmutableList()); | ||
|
|
||
| if (commitTasks.isEmpty()) { | ||
| // Avoid recording "empty" write operation | ||
| transaction = null; | ||
| return; | ||
| } | ||
|
|
||
| Schema schema = SchemaParser.fromJson(table.getTableSchemaJson()); | ||
|
|
||
| RowDelta rowDelta = transaction.newRowDelta(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why these two lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see now, please add a comment