Skip to content

[iceberg] inconsistent set-location between create or replace view / table #25425

@twuebi

Description

@twuebi

Hi all,

I've noticed an inconsistency when doing a CREATE OR REPLACE on a table vs a view when using trino with iceberg. With tables, trino will reuse the location of the table it's replacing, IcebergMetadata::beginCreateTable:

 ...
 String tableLocation = null;
 ...
 if (replace) {
  ...
  tableLocation = icebergTable.location();
  ...
 }

 if (tableLocation == null) {
      tableLocation = getTableLocation(tableMetadata.getProperties())
              .orElseGet(() -> catalog.defaultTableLocation(session, tableMetadata.getTable()));
  }
  ...
 transaction = newCreateTableTransaction(catalog, tableMetadata, session, replace, tableLocation, allowedExtraProperties);

When replacing a view, a new location is always generated TrinoRestCatalog::createView:

        viewBuilder = viewBuilder.withSchema(schema)
                .withQuery("trino", definition.getOriginalSql())
                .withDefaultNamespace(toRemoteNamespace(session, toNamespace(schemaViewName.getSchemaName())))
                .withDefaultCatalog(definition.getCatalog().orElse(null))
                .withProperties(properties.buildOrThrow())
                .withLocation(defaultTableLocation(session, schemaViewName));

which in presence of "iceberg.unique-table-location" = 'true' ends up generating a new view location for every replace view.

Is there a reason to generate a new location for every new view version?

Kind regards & thanks for the effort!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions