Skip to content

Commit

Permalink
fix materialized views to allow duplicated source tables
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernd Lunghamer committed Jan 13, 2022
1 parent 102d35b commit 87d9c8f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
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

0 comments on commit 87d9c8f

Please sign in to comment.