Skip to content

Commit

Permalink
Mark view creator in metastore
Browse files Browse the repository at this point in the history
To be able to track down what created given view. I.e. to distinguish
between things created by Hive connector and Iceberg connector, if they
share metastore.
  • Loading branch information
findepi committed Jul 20, 2021
1 parent 0aa32c0 commit 3c50304
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ public class HiveMetadata
implements TransactionalMetadata
{
public static final String PRESTO_VERSION_NAME = "presto_version";
public static final String TRINO_CREATED_BY = "trino_created_by";
public static final String PRESTO_QUERY_ID_NAME = "presto_query_id";
public static final String BUCKETING_VERSION = "bucketing_version";
public static final String TABLE_COMMENT = "comment";
Expand Down Expand Up @@ -1852,6 +1853,7 @@ public void createView(ConnectorSession session, SchemaTableName viewName, Conne
Map<String, String> properties = ImmutableMap.<String, String>builder()
.put(TABLE_COMMENT, PRESTO_VIEW_COMMENT)
.put(PRESTO_VIEW_FLAG, "true")
.put(TRINO_CREATED_BY, "Trino Hive connector")
.put(PRESTO_VERSION_NAME, prestoVersion)
.put(PRESTO_QUERY_ID_NAME, session.getQueryId())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ public class IcebergMetadata
public static final String DEPENDS_ON_TABLES = "dependsOnTables";

// Be compatible with views defined by the Hive connector, which can be useful under certain conditions.
private static final String TRINO_CREATED_BY = HiveMetadata.TRINO_CREATED_BY;
private static final String TRINO_CREATED_BY_VALUE = "Trino Iceberg connector";
private static final String PRESTO_VIEW_COMMENT = HiveMetadata.PRESTO_VIEW_COMMENT;
private static final String PRESTO_VERSION_NAME = HiveMetadata.PRESTO_VERSION_NAME;
private static final String PRESTO_QUERY_ID_NAME = HiveMetadata.PRESTO_QUERY_ID_NAME;
Expand Down Expand Up @@ -794,6 +796,7 @@ public void createView(ConnectorSession session, SchemaTableName viewName, Conne
HiveIdentity identity = new HiveIdentity(session);
Map<String, String> properties = ImmutableMap.<String, String>builder()
.put(PRESTO_VIEW_FLAG, "true")
.put(TRINO_CREATED_BY, TRINO_CREATED_BY_VALUE)
.put(PRESTO_VERSION_NAME, trinoVersion)
.put(PRESTO_QUERY_ID_NAME, session.getQueryId())
.put(TABLE_COMMENT, PRESTO_VIEW_COMMENT)
Expand Down Expand Up @@ -1056,6 +1059,7 @@ public void createMaterializedView(ConnectorSession session, SchemaTableName vie
.put(PRESTO_QUERY_ID_NAME, session.getQueryId())
.put(STORAGE_TABLE, storageTableName)
.put(PRESTO_VIEW_FLAG, "true")
.put(TRINO_CREATED_BY, TRINO_CREATED_BY_VALUE)
.put(TABLE_COMMENT, ICEBERG_MATERIALIZED_VIEW_COMMENT)
.build();

Expand Down

0 comments on commit 3c50304

Please sign in to comment.