Skip to content

[lake]Tolerate Iceberg lake table existent if the schema and properties matches#3601

Open
Guosmilesmile wants to merge 1 commit into
apache:mainfrom
Guosmilesmile:iceberg_create_table
Open

[lake]Tolerate Iceberg lake table existent if the schema and properties matches#3601
Guosmilesmile wants to merge 1 commit into
apache:mainfrom
Guosmilesmile:iceberg_create_table

Conversation

@Guosmilesmile

Copy link
Copy Markdown
Contributor

Purpose

Since we have support this feature in paimon and hudi, I think we should support it in iceberg too.

Brief change log

Tests

API and Format

Documentation

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the Iceberg lake catalog integration to tolerate an already-existing Iceberg table during Fluss table creation, as long as the existing table matches Fluss’s expected schema, partition spec, sort order, and required table properties. This aligns Iceberg behavior with existing “reuse existing lake table” support in other lake formats.

Changes:

  • Enhanced IcebergLakeCatalog#createTable to detect existing Iceberg tables and validate compatibility (schema/spec/sort/properties), allowing idempotent “recreate” when compatible and enforcing “empty table” when isCreatingFlussTable=true.
  • Added compatibility helper methods (isIcebergSchemaCompatibleWithSchema, isIcebergPartitionSpecCompatible, isIcebergSortOrderCompatible, isIcebergPropertiesCompatible) used for validation and unit testing.
  • Added comprehensive unit tests covering compatible reuse, first-time Fluss creation constraints, and various incompatibility scenarios.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
fluss-lake/fluss-lake-iceberg/src/main/java/org/apache/fluss/lake/iceberg/IcebergLakeCatalog.java Adds compatibility checks to tolerate existing Iceberg tables (or fail with detailed incompatibility reasons).
fluss-lake/fluss-lake-iceberg/src/test/java/org/apache/fluss/lake/iceberg/IcebergLakeCatalogTest.java Adds tests for idempotent create behavior and compatibility validation (schema/spec/sort/properties, empty vs non-empty).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1594 to +1603
private void appendDummyDataFile(Table icebergTable) {
DataFile dataFile =
DataFiles.builder(PartitionSpec.unpartitioned())
.withPath("/tmp/fluss-fake-file.parquet")
.withFileSizeInBytes(1024)
.withRecordCount(1L)
.withFormat(FileFormat.PARQUET)
.build();
icebergTable.newAppend().appendFile(dataFile).commit();
}
luoyuxia
luoyuxia previously approved these changes Jul 18, 2026

@luoyuxia luoyuxia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Guosmilesmile Thanks. Could you please help rebase main branch

@luoyuxia
luoyuxia dismissed their stale review July 18, 2026 09:45

Withdrawing approval after further review.

}
}

return true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Blocking: This compatibility check ignores Schema.identifierFieldIds(). A pre-created Iceberg table with the same columns, partition spec, sort order, and properties but no identifier fields therefore passes this check. IcebergLakeWriter#createRecordWriter then sees an empty identifier set and selects AppendOnlyTaskWriter, so UPDATE_BEFORE and DELETE records are appended instead of emitted as equality deletes, breaking primary-key semantics. Please compare identifier fields by resolved column names (raw IDs can differ between schemas) and add coverage for missing or incorrect identifiers.

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.

3 participants