mchades commented on code in PR #10831:
URL: https://github.com/apache/gravitino/pull/10831#discussion_r3125217373


##########
api/src/main/java/org/apache/gravitino/rel/Dialects.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.rel;
+
+/**
+ * Predefined SQL dialect identifiers used by {@link 
SQLRepresentation#dialect()}.
+ *
+ * <p>Dialect values are lowercase identifiers so they can be compared 
case-insensitively.
+ * Applications are free to use dialect strings that are not listed here; this 
class only provides
+ * constants for the dialects Gravitino recognizes out of the box.
+ */
+public final class Dialects {
+
+  /** The Trino SQL dialect. */
+  public static final String TRINO = "trino";
+
+  /** The Apache Spark SQL dialect. */
+  public static final String SPARK = "spark";
+
+  /** The Apache Hive SQL dialect. */
+  public static final String HIVE = "hive";
+
+  /** The Apache Flink SQL dialect. */
+  public static final String FLINK = "flink";
+
+  private Dialects() {}
+}

Review Comment:
   I suggest keeping `dialect` as string (with constants), not enum.
   
   This aligns with both our design and Iceberg:
   - Gravitino design doc defines dialect as a free-form string (not a fixed 
enum): 
https://github.com/mchades/gravitino/blob/defacfbe6/design-docs/gravitino-logical-view-management.md#L119-L121
   - Iceberg models dialect as `String` in `SQLViewRepresentation#dialect()`: 
https://github.com/apache/iceberg/blob/apache-iceberg-1.10.1/api/src/main/java/org/apache/iceberg/view/SQLViewRepresentation.java#L22-L33
   
   So `Dialects` is intended to provide well-known constants for typo 
reduction, not a closed set.



##########
api/src/main/java/org/apache/gravitino/rel/Representation.java:
##########
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.rel;
+
+import org.apache.gravitino.annotation.Unstable;
+
+/**
+ * A representation of a view's underlying definition. A view can carry 
multiple representations
+ * targeting different engines or dialects. Currently only the {@link 
#TYPE_SQL SQL} representation
+ * type is supported.
+ */
+@Unstable
+public interface Representation {
+
+  /** The representation type for SQL-based view definitions. */
+  String TYPE_SQL = "sql";

Review Comment:
   For `Representation#type`, I prefer keeping `String` in the public API.
   
   Although only `sql` is built-in today, `type` is designed for forward 
extensibility:
   - design doc (`type` is extensible): 
https://github.com/mchades/gravitino/blob/defacfbe6/design-docs/gravitino-logical-view-management.md#L115-L117
   - Iceberg `ViewRepresentation#type()` is also `String`: 
https://github.com/apache/iceberg/blob/apache-iceberg-1.10.1/api/src/main/java/org/apache/iceberg/view/ViewRepresentation.java#L21-L29
   - Iceberg also keeps `UnknownViewRepresentation`: 
https://github.com/apache/iceberg/blob/apache-iceberg-1.10.1/core/src/main/java/org/apache/iceberg/view/UnknownViewRepresentation.java#L23-L24
   
   So `TYPE_SQL` remains a stable built-in constant, while the API stays 
extensible.



##########
catalogs/catalog-lakehouse-iceberg/src/main/java/org/apache/gravitino/catalog/lakehouse/iceberg/IcebergView.java:
##########
@@ -68,6 +70,16 @@ public Map<String, String> properties() {
     return properties != null ? properties : Collections.emptyMap();
   }
 
+  @Override
+  public Column[] columns() {
+    return new Column[0];
+  }
+
+  @Override
+  public Representation[] representations() {
+    return new Representation[0];
+  }

Review Comment:
   Agreed this is a functional gap for the Iceberg load path.
   
   For this PR, I’m keeping scope on API surface and core dispatcher 
correctness. I will address Iceberg view metadata mapping (including 
`representations` from `LoadViewResponse`) in a dedicated follow-up PR.



##########
api/src/main/java/org/apache/gravitino/rel/ViewCatalog.java:
##########
@@ -54,4 +65,54 @@ default boolean viewExists(NameIdentifier ident) {
       return false;
     }
   }
+
+  /**
+   * Create a view in the catalog.
+   *
+   * @param ident A view identifier.
+   * @param comment The view comment, may be {@code null}.
+   * @param columns The output columns of the view.
+   * @param representations The representations of the view. At least one 
representation is
+   *     expected.
+   * @param defaultCatalog The default catalog used to resolve unqualified 
identifiers referenced by
+   *     the view definition, or {@code null} if not set.
+   * @param defaultSchema The default schema used to resolve unqualified 
identifiers referenced by
+   *     the view definition, or {@code null} if not set.
+   * @param properties The view properties.
+   * @return The created view metadata.
+   * @throws NoSuchSchemaException If the schema does not exist.
+   * @throws ViewAlreadyExistsException If the view already exists.
+   */
+  View createView(
+      NameIdentifier ident,
+      String comment,
+      Column[] columns,
+      Representation[] representations,
+      @Nullable String defaultCatalog,
+      @Nullable String defaultSchema,
+      Map<String, String> properties)
+      throws NoSuchSchemaException, ViewAlreadyExistsException;

Review Comment:
   Fixed in commit `defacfbe6`: `createView(...)` now annotates `comment` with 
`@Nullable` to match the JavaDoc.



##########
catalogs/catalog-lakehouse-iceberg/src/main/java/org/apache/gravitino/catalog/lakehouse/iceberg/IcebergView.java:
##########
@@ -68,6 +70,16 @@ public Map<String, String> properties() {
     return properties != null ? properties : Collections.emptyMap();
   }
 
+  @Override
+  public Column[] columns() {
+    return new Column[0];
+  }

Review Comment:
   Agreed. `columns()` should be populated from Iceberg view metadata when 
available.
   
   I will cover this together with `representations` mapping in the dedicated 
Iceberg follow-up PR, so this PR remains focused on API definition and core 
dispatcher fixes.



-- 
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]

Reply via email to