diqiu50 commented on code in PR #11926:
URL: https://github.com/apache/gravitino/pull/11926#discussion_r3655033731
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/CatalogConnectorMetadataAdapter.java:
##########
@@ -148,6 +155,83 @@ public GravitinoTable createTable(ConnectorTableMetadata
tableMetadata) {
return new GravitinoTable(schemaName, tableName, columns, comment,
properties);
}
+ /**
+ * Transform Gravitino view metadata to Trino ConnectorViewDefinition. Owner
is not supported by
+ * Gravitino views, so the resulting definition always has an empty owner;
since Trino requires an
+ * owner for run-as-definer views, {@code runAsInvoker} is always {@code
true}.
+ *
+ * @param view the Gravitino view
+ * @return the Trino ConnectorViewDefinition
+ */
+ public ConnectorViewDefinition getViewDefinition(GravitinoView view) {
+ Preconditions.checkArgument(
+ view.getSql() != null,
+ "View %s.%s has no Trino dialect SQL representation",
+ view.getSchemaName(),
+ view.getName());
+ List<ViewColumn> columns =
+ view.getColumns().stream()
+ .map(
+ column ->
+ new ViewColumn(
+ column.getName(),
+
dataTypeTransformer.getTrinoType(column.getType()).getTypeId(),
+ Optional.ofNullable(column.getComment())))
+ .collect(Collectors.toList());
+
+ return new ConnectorViewDefinition(
+ view.getSql(),
+ Optional.ofNullable(view.getDefaultCatalog()),
+ Optional.ofNullable(view.getDefaultSchema()),
+ columns,
+ Optional.ofNullable(view.getComment()),
+ Optional.empty(),
+ true,
+ List.of());
Review Comment:
fixed
##########
catalogs/catalog-hive/src/main/java/org/apache/gravitino/catalog/hive/HiveView.java:
##########
@@ -40,9 +40,15 @@
/**
* Represents a view stored in Hive Metastore (VIRTUAL_VIEW table type). The
SQL dialect is detected
- * from table properties: Trino views start with "/* Presto View:", Spark
views carry {@code
- * spark.sql.create.version}, Flink views carry properties prefixed with
{@code flink.}, and all
- * other views are treated as native Hive SQL views.
+ * from table properties: Trino views (written by this catalog) carry {@code
+ * gravitino.view.trino_dialect}, Spark views carry {@code
spark.sql.create.version}, Flink views
+ * carry properties prefixed with {@code flink.}, and all other views are
treated as native Hive SQL
+ * views.
+ *
+ * <p>Native Presto/Trino views created outside Gravitino use the {@code
presto_view} HMS property
+ * and encode their body as a base64-wrapped comment rather than plain SQL
text; since decoding that
+ * native format requires Trino's own serialization logic, this catalog does
not attempt to read it
+ * and such views are treated as Hive dialect (i.e. not exposed as
Trino-readable SQL).
Review Comment:
fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]