Skip to content

Commit

Permalink
Don't set materialized view owner for IcebergGlueCatalog for system s…
Browse files Browse the repository at this point in the history
…ecurity
  • Loading branch information
homar authored and dain committed Nov 28, 2023
1 parent aceb19e commit 01acd18
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public class TrinoGlueCatalog
private final AWSGlueAsync glueClient;
private final GlueMetastoreStats stats;
private final boolean hideMaterializedViewStorageTable;
private final boolean isUsingSystemSecurity;

private final Cache<SchemaTableName, com.amazonaws.services.glue.model.Table> glueTableCache = EvictableCacheBuilder.newBuilder()
// Even though this is query-scoped, this still needs to be bounded. information_schema queries can access large number of tables.
Expand All @@ -206,6 +207,7 @@ public TrinoGlueCatalog(
String trinoVersion,
AWSGlueAsync glueClient,
GlueMetastoreStats stats,
boolean isUsingSystemSecurity,
Optional<String> defaultSchemaLocation,
boolean useUniqueTableLocation,
boolean hideMaterializedViewStorageTable)
Expand All @@ -217,6 +219,7 @@ public TrinoGlueCatalog(
this.fileSystemFactory = requireNonNull(fileSystemFactory, "fileSystemFactory is null");
this.glueClient = requireNonNull(glueClient, "glueClient is null");
this.stats = requireNonNull(stats, "stats is null");
this.isUsingSystemSecurity = isUsingSystemSecurity;
this.defaultSchemaLocation = requireNonNull(defaultSchemaLocation, "defaultSchemaLocation is null");
this.hideMaterializedViewStorageTable = hideMaterializedViewStorageTable;
}
Expand Down Expand Up @@ -1173,7 +1176,7 @@ private void createMaterializedViewWithStorageTable(
TableInput materializedViewTableInput = getMaterializedViewTableInput(
viewName.getTableName(),
encodeMaterializedViewData(fromConnectorMaterializedViewDefinition(definition)),
session.getUser(),
isUsingSystemSecurity ? null : session.getUser(),
createMaterializedViewProperties(session, storageTable));

if (existing.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.trino.plugin.hive.metastore.glue.GlueHiveMetastoreConfig;
import io.trino.plugin.hive.metastore.glue.GlueMetastoreStats;
import io.trino.plugin.iceberg.IcebergConfig;
import io.trino.plugin.iceberg.IcebergSecurityConfig;
import io.trino.plugin.iceberg.catalog.IcebergTableOperationsProvider;
import io.trino.plugin.iceberg.catalog.TrinoCatalog;
import io.trino.plugin.iceberg.catalog.TrinoCatalogFactory;
Expand All @@ -31,6 +32,7 @@

import java.util.Optional;

import static io.trino.plugin.iceberg.IcebergSecurityConfig.IcebergSecurity.SYSTEM;
import static java.util.Objects.requireNonNull;

public class TrinoGlueCatalogFactory
Expand All @@ -47,6 +49,7 @@ public class TrinoGlueCatalogFactory
private final boolean isUniqueTableLocation;
private final boolean hideMaterializedViewStorageTable;
private final GlueMetastoreStats stats;
private final boolean isUsingSystemSecurity;

@Inject
public TrinoGlueCatalogFactory(
Expand All @@ -58,6 +61,7 @@ public TrinoGlueCatalogFactory(
GlueHiveMetastoreConfig glueConfig,
IcebergConfig icebergConfig,
IcebergGlueCatalogConfig catalogConfig,
IcebergSecurityConfig securityConfig,
GlueMetastoreStats stats,
AWSGlueAsync glueClient)
{
Expand All @@ -72,6 +76,7 @@ public TrinoGlueCatalogFactory(
this.isUniqueTableLocation = icebergConfig.isUniqueTableLocation();
this.hideMaterializedViewStorageTable = icebergConfig.isHideMaterializedViewStorageTable();
this.stats = requireNonNull(stats, "stats is null");
this.isUsingSystemSecurity = securityConfig.getSecuritySystem() == SYSTEM;
}

@Managed
Expand All @@ -93,6 +98,7 @@ public TrinoCatalog create(ConnectorIdentity identity)
trinoVersion,
glueClient,
stats,
isUsingSystemSecurity,
defaultSchemaLocation,
isUniqueTableLocation,
hideMaterializedViewStorageTable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ protected TrinoCatalog createTrinoCatalog(boolean useUniqueTableLocations)
"test",
glueClient,
new GlueMetastoreStats(),
false,
Optional.empty(),
useUniqueTableLocations,
new IcebergConfig().isHideMaterializedViewStorageTable());
Expand Down Expand Up @@ -157,6 +158,7 @@ public void testDefaultLocation()
"test",
glueClient,
new GlueMetastoreStats(),
false,
Optional.of(tmpDirectory.toAbsolutePath().toString()),
false,
new IcebergConfig().isHideMaterializedViewStorageTable());
Expand Down

0 comments on commit 01acd18

Please sign in to comment.