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

REST catalog doesn't return old history if we execute CREATE OR REPLACE TABLE statement #11777

Open
1 of 3 tasks
ebyhr opened this issue Dec 13, 2024 · 1 comment · May be fixed by #11779
Open
1 of 3 tasks

REST catalog doesn't return old history if we execute CREATE OR REPLACE TABLE statement #11777

ebyhr opened this issue Dec 13, 2024 · 1 comment · May be fixed by #11779
Labels
bug Something isn't working

Comments

@ebyhr
Copy link
Contributor

ebyhr commented Dec 13, 2024

Apache Iceberg version

1.7.1 (latest release)

Query engine

Trino

Please describe the bug 🐞

trinodb/trino#24312 is trying to use org.apache.iceberg.MetadataTableUtils#createMetadataTableInstance method for history metadata table. Only REST catalog doesn't return the past history if we execute CREATE OR REPLACE TABLE statement.

trino:tpch> TABLE "region$history";
          made_current_at           |     snapshot_id     | parent_id | is_current_ancestor
------------------------------------+---------------------+-----------+---------------------
 2024-12-13 16:26:02.387 Asia/Tokyo | 4753270524621689028 |      NULL | true
(1 row)

trino:tpch> CREATE OR REPLACE TABLE region AS SELECT * FROM orders;
CREATE TABLE: 15000 rows

trino:tpch> TABLE "region$history";
          made_current_at           |     snapshot_id     | parent_id | is_current_ancestor
------------------------------------+---------------------+-----------+---------------------
 2024-12-13 16:27:51.756 Asia/Tokyo | 7793069171159305791 |      NULL | true
(1 row)

trino:tpch> SHOW CREATE TABLE region;
                                                                          Create Table
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
 CREATE TABLE iceberg.tpch.region (
    orderkey bigint,
    custkey bigint,
    orderstatus varchar,
    totalprice double,
    orderdate date,
    orderpriority varchar,
    clerk varchar,
    shippriority integer,
    comment varchar
 )
 WITH (
    format = 'PARQUET',
    format_version = 2,
    location = '/var/folders/9s/_zwn4r_n2_9bp0krllp1pl3c0000gp/T/a6a26fac-b6be-4c9c-b05b-cbe7ec894b2f/iceberg_data/tpch/region-4f41a42ee7f84d3093d85649bc557e46'
 )
(1 row)

region-4f41a42ee7f84d3093d85649bc557e46.zip

The following request contains RemoveSnapshotRef that clears existing snapshot logs.

TableMetadata.Builder metadataBuilder = TableMetadata.buildFrom(base);
request.updates().forEach(update -> update.applyTo(metadataBuilder));
TableMetadata updated = metadataBuilder.build();

https://apache-iceberg.slack.com/archives/C03LG1D563F/p1733195549342209

Willingness to contribute

  • I can contribute a fix for this bug independently
  • I would be willing to contribute a fix for this bug with guidance from the Iceberg community
  • I cannot contribute a fix for this bug at this time
@ebyhr ebyhr added the bug Something isn't working label Dec 13, 2024
@ebyhr
Copy link
Contributor Author

ebyhr commented Dec 13, 2024

I think we need to modify RemoveSnapshotRef for providing an option to clear snapshot-logs or not, or add a new MetadataUpdate class (e.g. ResetMainBranch).

@ebyhr ebyhr linked a pull request Dec 13, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant