Skip to content

Commit

Permalink
Simplify code in TrinoGlueCatalog and TrinoHiveCatalog
Browse files Browse the repository at this point in the history
  • Loading branch information
krvikash authored and ebyhr committed Oct 22, 2024
1 parent e2068c6 commit ef686f7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1314,22 +1314,20 @@ private ConnectorMaterializedViewDefinition createMaterializedViewDefinition(
materializedViewParameters));
}

SchemaTableName storageTableName;
if (storageTable != null) {
String storageSchema = Optional.ofNullable(materializedViewParameters.get(STORAGE_SCHEMA))
.orElse(viewName.getSchemaName());
SchemaTableName storageTableName = new SchemaTableName(storageSchema, storageTable);
storageTableName = new SchemaTableName(storageSchema, storageTable);

String viewOriginalText = table.getViewOriginalText();
if (viewOriginalText == null) {
if (table.getViewOriginalText() == null) {
throw new TrinoException(ICEBERG_BAD_DATA, "Materialized view did not have original text " + viewName);
}
return getMaterializedViewDefinition(
Optional.ofNullable(table.getOwner()),
viewOriginalText,
storageTableName);
}
else {
storageTableName = new SchemaTableName(viewName.getSchemaName(), tableNameWithType(viewName.getTableName(), MATERIALIZED_VIEW_STORAGE));
}

SchemaTableName storageTableName = new SchemaTableName(viewName.getSchemaName(), tableNameWithType(viewName.getTableName(), MATERIALIZED_VIEW_STORAGE));
return getMaterializedViewDefinition(
Optional.ofNullable(table.getOwner()),
table.getViewOriginalText(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -740,18 +740,16 @@ protected Optional<ConnectorMaterializedViewDefinition> doGetMaterializedView(Co
materializedView.getParameters()));
}

SchemaTableName storageTableName;
if (storageTable != null) {
String storageSchema = Optional.ofNullable(materializedView.getParameters().get(STORAGE_SCHEMA))
.orElse(viewName.getSchemaName());
SchemaTableName storageTableName = new SchemaTableName(storageSchema, storageTable);
return Optional.of(getMaterializedViewDefinition(
materializedView.getOwner(),
materializedView.getViewOriginalText()
.orElseThrow(() -> new TrinoException(HIVE_INVALID_METADATA, "No view original text: " + viewName)),
storageTableName));
storageTableName = new SchemaTableName(storageSchema, storageTable);
}
else {
storageTableName = new SchemaTableName(viewName.getSchemaName(), IcebergTableName.tableNameWithType(viewName.getTableName(), MATERIALIZED_VIEW_STORAGE));
}

SchemaTableName storageTableName = new SchemaTableName(viewName.getSchemaName(), IcebergTableName.tableNameWithType(viewName.getTableName(), MATERIALIZED_VIEW_STORAGE));
return Optional.of(getMaterializedViewDefinition(
materializedView.getOwner(),
materializedView.getViewOriginalText()
Expand Down

0 comments on commit ef686f7

Please sign in to comment.