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

fix materialized views to allow duplicated source tables without breaking the metadata schema #10570

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,7 @@ public Optional<ConnectorOutputMetadata> finishRefreshMaterializedView(
.map(handle -> (IcebergTableHandle) handle)
.filter(handle -> handle.getSnapshotId().isPresent())
.map(handle -> handle.getSchemaTableName() + "=" + handle.getSnapshotId().get())
.distinct()
.collect(joining(","));

// Update the 'dependsOnTables' property that tracks tables on which the materialized view depends and the corresponding snapshot ids of the tables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,20 @@ public void testCreateWithInvalidPropertyFails()
.hasMessage("Catalog 'iceberg' does not support materialized view property 'invalid_property'");
}

@Test
public void testCreateWithDuplicateSourceTableSucceeds()
{
assertUpdate("" +
"CREATE MATERIALIZED VIEW materialized_view_with_duplicate_source AS " +
"SELECT _bigint, _date FROM base_table1 " +
"UNION ALL " +
"SELECT _bigint, _date FROM base_table1 ");

assertUpdate("REFRESH MATERIALIZED VIEW materialized_view_with_duplicate_source", 12);

assertQuery("SELECT count(*) FROM materialized_view_with_duplicate_source", "VALUES 12");
}

@Test
public void testShowCreate()
{
Expand Down