You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "diqiu50 (via GitHub)" <gi...@apache.org> on 2026/06/02 07:19:34 UTC

[PR] [#11348] feat(flink-connector): Flink connector view support to Iceberg and Paimon catalogs [gravitino]

diqiu50 opened a new pull request, #11349:
URL: https://github.com/apache/gravitino/pull/11349

   ### What changes were proposed in this pull request?
   
   - Fix `GravitinoPaimonCatalog.dropTable` to fall back to `asViewCatalog().dropView()` when `purgeTable` returns false, so `DROP VIEW` works correctly on Paimon catalogs.
   - Move the 9 view integration tests from `FlinkHiveCatalogIT` into the shared `FlinkCommonIT` base class, controlled by a `supportViewOperation()` hook and a `baseTableConnectorClause()` helper.
   - Enable view tests for Iceberg (Hive + REST backends) and Paimon (Hive + JDBC backends).
   
   ### Why are the changes needed?
   
   The Flink connector only supported and tested views for the Hive catalog. Iceberg and Paimon catalogs already implement `asViewCatalog()` on the server side but had no Flink-level test coverage, and `GravitinoPaimonCatalog.dropTable` had a bug that prevented `DROP VIEW` from working.
   
   Fix: #11348
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. `CREATE/DROP/ALTER/SHOW VIEW` now work in Flink SQL when using an Iceberg or Paimon catalog backed by Gravitino.
   
   ### How was this patch tested?
   
   Added 9 view integration tests (create, list, drop, rename, replace body, query, if-not-exists variants, table/view list separation) to `FlinkCommonIT`. Tests run against Iceberg Hive/REST backends and Paimon Hive/JDBC backends via Docker integration tests.


-- 
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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#11348] feat(flink-connector): Flink connector view support to Iceberg and Paimon catalogs [gravitino]

Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 commented on code in PR #11349:
URL: https://github.com/apache/gravitino/pull/11349#discussion_r3363259046


##########
flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/paimon/GravitinoPaimonCatalog.java:
##########
@@ -103,6 +108,25 @@ protected AbstractCatalog realCatalog() {
   // DDL — route through Gravitino (single source of truth)
   // ---------------------------------------------------------------------------
 
+  @Override
+  protected List<String> viewDialectFallbackOrder() {
+    return Arrays.asList(Dialects.FLINK, Dialects.QUERY_DIALECT);

Review Comment:
   added



-- 
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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#11348] feat(flink-connector): Flink connector view support to Iceberg and Paimon catalogs [gravitino]

Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #11349:
URL: https://github.com/apache/gravitino/pull/11349#discussion_r3361508885


##########
flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/paimon/GravitinoPaimonCatalog.java:
##########
@@ -103,6 +108,25 @@ protected AbstractCatalog realCatalog() {
   // DDL — route through Gravitino (single source of truth)
   // ---------------------------------------------------------------------------
 
+  @Override
+  protected List<String> viewDialectFallbackOrder() {
+    return Arrays.asList(Dialects.FLINK, Dialects.QUERY_DIALECT);
+  }
+
+  @Override
+  protected Representation[] buildViewRepresentations(ResolvedCatalogView view) {
+    String sql = view.getExpandedQuery();
+    return new Representation[] {
+      SQLRepresentation.builder().withDialect(Dialects.FLINK).withSql(sql).build(),
+      SQLRepresentation.builder().withDialect(Dialects.QUERY_DIALECT).withSql(sql).build()
+    };
+  }
+
+  @Override
+  protected boolean dropTableEntry(NameIdentifier ident) {
+    return catalog().asTableCatalog().purgeTable(ident);

Review Comment:
   why using purgeTable for dropTable?



-- 
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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#11348] feat(flink-connector): Flink connector view support to Iceberg and Paimon catalogs [gravitino]

Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades merged PR #11349:
URL: https://github.com/apache/gravitino/pull/11349


-- 
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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#11348] feat(flink-connector): Flink connector view support to Iceberg and Paimon catalogs [gravitino]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #11349:
URL: https://github.com/apache/gravitino/pull/11349#discussion_r3339370739


##########
flink-connector/flink-common/src/test/java/org/apache/gravitino/flink/connector/integration/test/FlinkCommonIT.java:
##########
@@ -812,4 +825,281 @@ && defaultValueWithNullLiterals()) {
       Assertions.assertEquals(expected[i].nullable(), actual[i].nullable());
     }
   }
+
+  @Test
+  @EnabledIf("supportViewOperation")
+  public void testCreateView() {
+    String schemaName = "test_create_view_db";
+    String viewName = "test_view_create";
+    String tableName = "test_view_base_table";
+    doWithSchema(
+        currentCatalog(),
+        schemaName,
+        catalog -> {
+          TestUtils.assertTableResult(
+              sql("CREATE TABLE %s (id INT, name STRING)%s", tableName, baseTableConnectorClause()),
+              ResultKind.SUCCESS);
+          TestUtils.assertTableResult(
+              sql(
+                  "CREATE VIEW %s COMMENT 'view comment' AS SELECT id, name FROM %s",
+                  viewName, tableName),
+              ResultKind.SUCCESS);
+
+          org.apache.gravitino.rel.ViewCatalog viewCatalog = catalog.asViewCatalog();
+          org.apache.gravitino.rel.View view =
+              viewCatalog.loadView(NameIdentifier.of(schemaName, viewName));
+          Assertions.assertEquals(viewName, view.name());
+          Assertions.assertEquals("view comment", view.comment());
+          Assertions.assertEquals(1, view.representations().length);
+          Assertions.assertInstanceOf(
+              org.apache.gravitino.rel.SQLRepresentation.class, view.representations()[0]);
+
+          Optional<org.apache.flink.table.catalog.Catalog> flinkCatalog =
+              tableEnv.getCatalog(catalog.name());
+          Assertions.assertTrue(flinkCatalog.isPresent());
+          try {
+            CatalogBaseTable flinkTable =
+                flinkCatalog.get().getTable(new ObjectPath(schemaName, viewName));
+            Assertions.assertEquals(CatalogBaseTable.TableKind.VIEW, flinkTable.getTableKind());
+          } catch (org.apache.flink.table.catalog.exceptions.TableNotExistException e) {
+            Assertions.fail("view should exist in Flink catalog: " + e.getMessage());
+          }
+        },
+        true);
+  }
+
+  @Test
+  @EnabledIf("supportViewOperation")
+  public void testListViews() {
+    String schemaName = "test_list_views_db";
+    String tableName = "test_list_view_base";
+    String view1 = "test_list_view_1";
+    String view2 = "test_list_view_2";
+    doWithSchema(
+        currentCatalog(),
+        schemaName,
+        catalog -> {
+          TestUtils.assertTableResult(
+              sql("CREATE TABLE %s (id INT)%s", tableName, baseTableConnectorClause()),
+              ResultKind.SUCCESS);
+          TestUtils.assertTableResult(
+              sql("CREATE VIEW %s AS SELECT id FROM %s", view1, tableName), ResultKind.SUCCESS);
+          TestUtils.assertTableResult(
+              sql("CREATE VIEW %s AS SELECT id FROM %s", view2, tableName), ResultKind.SUCCESS);
+
+          List<String> views = Arrays.asList(tableEnv.listViews());
+          Assertions.assertTrue(views.contains(view1), "view1 not found in SHOW VIEWS");
+          Assertions.assertTrue(views.contains(view2), "view2 not found in SHOW VIEWS");
+          Assertions.assertFalse(views.contains(tableName), "table should not appear in listViews");
+
+          org.apache.gravitino.rel.ViewCatalog viewCatalog = catalog.asViewCatalog();
+          NameIdentifier[] gravitinoViews =
+              viewCatalog.listViews(org.apache.gravitino.Namespace.of(schemaName));
+          List<String> gravitinoViewNames =
+              Arrays.stream(gravitinoViews).map(NameIdentifier::name).collect(Collectors.toList());
+          Assertions.assertTrue(gravitinoViewNames.contains(view1));
+          Assertions.assertTrue(gravitinoViewNames.contains(view2));
+        },
+        true);
+  }
+
+  @Test
+  @EnabledIf("supportViewOperation")
+  public void testDropView() {
+    String schemaName = "test_drop_view_db";
+    String tableName = "test_drop_view_base";
+    String viewName = "test_view_drop";
+    doWithSchema(
+        currentCatalog(),
+        schemaName,
+        catalog -> {
+          TestUtils.assertTableResult(
+              sql("CREATE TABLE %s (id INT)%s", tableName, baseTableConnectorClause()),
+              ResultKind.SUCCESS);
+          TestUtils.assertTableResult(
+              sql("CREATE VIEW %s AS SELECT id FROM %s", viewName, tableName), ResultKind.SUCCESS);
+
+          org.apache.gravitino.rel.ViewCatalog viewCatalog = catalog.asViewCatalog();
+          Assertions.assertTrue(
+              viewCatalog.viewExists(NameIdentifier.of(schemaName, viewName)),
+              "view should exist before drop");
+
+          TestUtils.assertTableResult(sql("DROP VIEW %s", viewName), ResultKind.SUCCESS);
+
+          Assertions.assertFalse(
+              viewCatalog.viewExists(NameIdentifier.of(schemaName, viewName)),
+              "view should not exist after drop");
+        },
+        true);
+  }
+
+  @Test
+  @EnabledIf("supportViewOperation")
+  public void testAlterViewRename() {
+    String schemaName = "test_rename_view_db";
+    String tableName = "test_rename_view_base";
+    String viewName = "test_view_rename_src";
+    String newViewName = "test_view_rename_dst";
+    doWithSchema(
+        currentCatalog(),
+        schemaName,
+        catalog -> {
+          TestUtils.assertTableResult(
+              sql("CREATE TABLE %s (id INT)%s", tableName, baseTableConnectorClause()),
+              ResultKind.SUCCESS);
+          TestUtils.assertTableResult(
+              sql("CREATE VIEW %s AS SELECT id FROM %s", viewName, tableName), ResultKind.SUCCESS);
+
+          TestUtils.assertTableResult(
+              sql("ALTER VIEW %s RENAME TO %s", viewName, newViewName), ResultKind.SUCCESS);
+
+          org.apache.gravitino.rel.ViewCatalog viewCatalog = catalog.asViewCatalog();
+          Assertions.assertFalse(
+              viewCatalog.viewExists(NameIdentifier.of(schemaName, viewName)),
+              "old view name should not exist");
+          Assertions.assertTrue(
+              viewCatalog.viewExists(NameIdentifier.of(schemaName, newViewName)),
+              "new view name should exist");
+        },
+        true);
+  }
+
+  @Test
+  @EnabledIf("supportViewOperation")
+  public void testAlterViewReplaceBody() {
+    String schemaName = "test_replace_view_db";
+    String tableName = "test_replace_view_base";
+    String viewName = "test_view_replace";
+    doWithSchema(
+        currentCatalog(),
+        schemaName,
+        catalog -> {
+          TestUtils.assertTableResult(
+              sql("CREATE TABLE %s (id INT, name STRING)%s", tableName, baseTableConnectorClause()),
+              ResultKind.SUCCESS);
+          TestUtils.assertTableResult(
+              sql("CREATE VIEW %s AS SELECT id FROM %s", viewName, tableName), ResultKind.SUCCESS);
+
+          TestUtils.assertTableResult(
+              sql("ALTER VIEW %s AS SELECT id, name FROM %s", viewName, tableName),
+              ResultKind.SUCCESS);
+
+          org.apache.gravitino.rel.ViewCatalog viewCatalog = catalog.asViewCatalog();
+          org.apache.gravitino.rel.View view =
+              viewCatalog.loadView(NameIdentifier.of(schemaName, viewName));
+          Assertions.assertEquals(1, view.representations().length);
+          org.apache.gravitino.rel.SQLRepresentation rep =
+              (org.apache.gravitino.rel.SQLRepresentation) view.representations()[0];

Review Comment:
   These new view tests use fully qualified class names (`org.apache.gravitino.rel.ViewCatalog`, `org.apache.gravitino.rel.View`, `org.apache.gravitino.rel.SQLRepresentation`, `org.apache.gravitino.Namespace`, and `org.apache.flink.table.catalog.exceptions.TableNotExistException`) instead of regular imports. This violates the repo's import convention (AGENTS.md): prefer normal Java imports and avoid FQN unless a real name conflict requires it. None of these types collide with existing imports — note `TableNotExistException` is already imported at the top of the file, so the FQN in the catch is unnecessary. Only `org.apache.flink.table.catalog.Catalog` truly needs an FQN (or alias) because `org.apache.gravitino.Catalog` is already imported. Please add proper imports for the gravitino `rel.*` and `Namespace` types, drop the FQN at the call sites, and use the already-imported `TableNotExistException`.



-- 
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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#11348] feat(flink-connector): Flink connector view support to Iceberg and Paimon catalogs [gravitino]

Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 commented on code in PR #11349:
URL: https://github.com/apache/gravitino/pull/11349#discussion_r3363212629


##########
flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/catalog/BaseCatalog.java:
##########
@@ -332,6 +333,16 @@ public void dropTable(ObjectPath tablePath, boolean ignoreIfNotExists)
     }
   }
 
+  /**
+   * Drops the table entry. Subclasses may override to use a different drop strategy (e.g., purge).

Review Comment:
   For Paimon, GravitinoPaimonCatalog overrides it to call purgeTable(). 



-- 
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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#11348] feat(flink-connector): Flink connector view support to Iceberg and Paimon catalogs [gravitino]

Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #11349:
URL: https://github.com/apache/gravitino/pull/11349#discussion_r3361513419


##########
flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/paimon/GravitinoPaimonCatalog.java:
##########
@@ -103,6 +108,25 @@ protected AbstractCatalog realCatalog() {
   // DDL — route through Gravitino (single source of truth)
   // ---------------------------------------------------------------------------
 
+  @Override
+  protected List<String> viewDialectFallbackOrder() {
+    return Arrays.asList(Dialects.FLINK, Dialects.QUERY_DIALECT);

Review Comment:
   should add HIVE dialect?



-- 
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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#11348] feat(flink-connector): Flink connector view support to Iceberg and Paimon catalogs [gravitino]

Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 commented on code in PR #11349:
URL: https://github.com/apache/gravitino/pull/11349#discussion_r3363219117


##########
flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/paimon/GravitinoPaimonCatalog.java:
##########
@@ -103,6 +108,25 @@ protected AbstractCatalog realCatalog() {
   // DDL — route through Gravitino (single source of truth)
   // ---------------------------------------------------------------------------
 
+  @Override
+  protected List<String> viewDialectFallbackOrder() {
+    return Arrays.asList(Dialects.FLINK, Dialects.QUERY_DIALECT);
+  }
+
+  @Override
+  protected Representation[] buildViewRepresentations(ResolvedCatalogView view) {
+    String sql = view.getExpandedQuery();
+    return new Representation[] {
+      SQLRepresentation.builder().withDialect(Dialects.FLINK).withSql(sql).build(),
+      SQLRepresentation.builder().withDialect(Dialects.QUERY_DIALECT).withSql(sql).build()
+    };
+  }
+
+  @Override
+  protected boolean dropTableEntry(NameIdentifier ident) {
+    return catalog().asTableCatalog().purgeTable(ident);

Review Comment:
   For Paimon managed tables, we use purgeTable() to ensure data files are cleaned up when a table is dropped from Flink



-- 
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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#11348] feat(flink-connector): Flink connector view support to Iceberg and Paimon catalogs [gravitino]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #11349:
URL: https://github.com/apache/gravitino/pull/11349#issuecomment-4600698666

   <!-- coverage-report -->
   ### Code Coverage Report
   |Overall Project|66.76% **`-0.09%`**|:green_circle:|
   |:-|:-|:-:|
   |Files changed|63.65%|:green_circle:|
   <br>
   
   |Module|Coverage||
   |:-|:-|:-:|
   |aliyun|1.72%|:red_circle:|
   |api|46.82%|:green_circle:|
   |authorization-common|85.96%|:green_circle:|
   |aws|3.66%|:red_circle:|
   |azure|2.47%|:red_circle:|
   |catalog-common|10.04%|:red_circle:|
   |catalog-fileset|80.33%|:green_circle:|
   |catalog-glue|66.08%|:green_circle:|
   |catalog-hive|79.55%|:green_circle:|
   |catalog-jdbc-clickhouse|80.02%|:green_circle:|
   |catalog-jdbc-common|45.31%|:green_circle:|
   |catalog-jdbc-doris|80.28%|:green_circle:|
   |catalog-jdbc-hologres|54.03%|:green_circle:|
   |catalog-jdbc-mysql|79.23%|:green_circle:|
   |catalog-jdbc-oceanbase|78.38%|:green_circle:|
   |catalog-jdbc-postgresql|82.29%|:green_circle:|
   |catalog-jdbc-starrocks|78.51%|:green_circle:|
   |catalog-kafka|77.01%|:green_circle:|
   |catalog-lakehouse-generic|44.89%|:green_circle:|
   |catalog-lakehouse-hudi|79.1%|:green_circle:|
   |catalog-lakehouse-iceberg|85.74%|:green_circle:|
   |catalog-lakehouse-paimon|79.29%|:green_circle:|
   |catalog-model|77.72%|:green_circle:|
   |cli|44.51%|:green_circle:|
   |client-java|77.91%|:green_circle:|
   |common|49.99%|:green_circle:|
   |core|82.47% **`-0.81%`**|:green_circle:|
   |filesystem-hadoop3|76.97%|:green_circle:|
   |flink|0.0%|:red_circle:|
   |flink-common|41.34% **`-4.14%`**|:green_circle:|
   |flink-runtime|0.0%|:red_circle:|
   |gcp|14.12%|:red_circle:|
   |hadoop-common|10.39%|:red_circle:|
   |hive-metastore-common|53.26%|:green_circle:|
   |iceberg-common|56.75%|:green_circle:|
   |iceberg-rest-server|72.26%|:green_circle:|
   |idp-basic|85.99%|:green_circle:|
   |integration-test-common|0.0%|:red_circle:|
   |jobs|66.17%|:green_circle:|
   |lance-common|20.83%|:red_circle:|
   |lance-rest-server|60.27%|:green_circle:|
   |lineage|53.02%|:green_circle:|
   |optimizer|82.87%|:green_circle:|
   |optimizer-api|21.95%|:red_circle:|
   |server|85.73%|:green_circle:|
   |server-common|73.66% **`+2.26%`**|:green_circle:|
   |spark|32.79%|:red_circle:|
   |spark-common|39.75%|:red_circle:|
   |trino-connector|39.44%|:red_circle:|
   
   <details>
   <summary>Files</summary>
   
   |Module|File|Coverage||
   |:-|:-|:-|:-:|
   |core|[CatalogMetaService.java](https://github.com/diqiu50/gravitino/blob/fe00eb86a2e915e659204564e2fa490c2b337a06/core/src/main/java/org/apache/gravitino/storage/relational/service/CatalogMetaService.java)|98.88%|:green_circle:|
   ||[Configs.java](https://github.com/diqiu50/gravitino/blob/fe00eb86a2e915e659204564e2fa490c2b337a06/core/src/main/java/org/apache/gravitino/Configs.java)|97.89%|:green_circle:|
   ||[CatalogManager.java](https://github.com/diqiu50/gravitino/blob/fe00eb86a2e915e659204564e2fa490c2b337a06/core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java)|67.02%|:green_circle:|
   ||[RelationalEntityStore.java](https://github.com/diqiu50/gravitino/blob/fe00eb86a2e915e659204564e2fa490c2b337a06/core/src/main/java/org/apache/gravitino/storage/relational/RelationalEntityStore.java)|54.88%|:red_circle:|
   ||[GravitinoEnv.java](https://github.com/diqiu50/gravitino/blob/fe00eb86a2e915e659204564e2fa490c2b337a06/core/src/main/java/org/apache/gravitino/GravitinoEnv.java)|11.83%|:red_circle:|
   |flink-common|[GravitinoPaimonCatalog.java](https://github.com/diqiu50/gravitino/blob/fe00eb86a2e915e659204564e2fa490c2b337a06/flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/paimon/GravitinoPaimonCatalog.java)|80.0%|:green_circle:|
   ||[BaseCatalog.java](https://github.com/diqiu50/gravitino/blob/fe00eb86a2e915e659204564e2fa490c2b337a06/flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/catalog/BaseCatalog.java)|27.79%|:red_circle:|
   |server-common|[JcasbinAuthorizationLookups.java](https://github.com/diqiu50/gravitino/blob/fe00eb86a2e915e659204564e2fa490c2b337a06/server-common/src/main/java/org/apache/gravitino/server/authorization/jcasbin/JcasbinAuthorizationLookups.java)|84.62%|:green_circle:|
   ||[JcasbinAuthorizer.java](https://github.com/diqiu50/gravitino/blob/fe00eb86a2e915e659204564e2fa490c2b337a06/server-common/src/main/java/org/apache/gravitino/server/authorization/jcasbin/JcasbinAuthorizer.java)|83.85%|:green_circle:|
   ||[JcasbinChangePoller.java](https://github.com/diqiu50/gravitino/blob/fe00eb86a2e915e659204564e2fa490c2b337a06/server-common/src/main/java/org/apache/gravitino/server/authorization/jcasbin/JcasbinChangePoller.java)|63.5%|:green_circle:|
   
   </details>


-- 
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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#11348] feat(flink-connector): Flink connector view support to Iceberg and Paimon catalogs [gravitino]

Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #11349:
URL: https://github.com/apache/gravitino/pull/11349#discussion_r3361414102


##########
flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/catalog/BaseCatalog.java:
##########
@@ -332,6 +333,16 @@ public void dropTable(ObjectPath tablePath, boolean ignoreIfNotExists)
     }
   }
 
+  /**
+   * Drops the table entry. Subclasses may override to use a different drop strategy (e.g., purge).

Review Comment:
   How can different drop strategies, such as purge, be controlled when the function parameter is limited to `NameIdentifier`?



##########
api/src/main/java/org/apache/gravitino/rel/Dialects.java:
##########
@@ -39,5 +39,12 @@ public final class Dialects {
   /** The Apache Flink SQL dialect. */
   public static final String FLINK = "flink";
 
+  /**
+   * A dialect key for the canonical SQL representation of a view, used as a fallback when no
+   * engine-specific dialect (e.g. {@link #FLINK}, {@link #HIVE}) is available or preserved by the
+   * underlying metastore.
+   */
+  public static final String QUERY_DIALECT = "query";

Review Comment:
   Only the Paimon catalog utilizes `query`, so it is unnecessary to include it in the API module.



-- 
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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#11348] feat(flink-connector): Flink connector view support to Iceberg and Paimon catalogs [gravitino]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #11349:
URL: https://github.com/apache/gravitino/pull/11349#discussion_r3356122909


##########
flink-connector/flink-common/src/test/java/org/apache/gravitino/flink/connector/integration/test/FlinkCommonIT.java:
##########
@@ -812,4 +829,285 @@ && defaultValueWithNullLiterals()) {
       Assertions.assertEquals(expected[i].nullable(), actual[i].nullable());
     }
   }
+
+  @Test
+  @EnabledIf("supportViewOperation")
+  public void testCreateView() {
+    String schemaName = "test_create_view_db";
+    String viewName = "test_view_create";
+    String tableName = "test_view_base_table";
+    doWithSchema(
+        currentCatalog(),
+        schemaName,
+        catalog -> {
+          TestUtils.assertTableResult(
+              sql("CREATE TABLE %s (id INT, name STRING)%s", tableName, baseTableConnectorClause()),
+              ResultKind.SUCCESS);
+          TestUtils.assertTableResult(
+              sql(
+                  "CREATE VIEW %s COMMENT 'view comment' AS SELECT id, name FROM %s",
+                  viewName, tableName),
+              ResultKind.SUCCESS);
+
+          ViewCatalog viewCatalog = catalog.asViewCatalog();
+          View view = viewCatalog.loadView(NameIdentifier.of(schemaName, viewName));
+          Assertions.assertEquals(viewName, view.name());
+          Assertions.assertEquals("view comment", view.comment());
+          Assertions.assertEquals(1, view.representations().length);
+          Assertions.assertInstanceOf(SQLRepresentation.class, view.representations()[0]);

Review Comment:
   `GravitinoPaimonCatalog` now stores multiple SQL representations for a view (e.g., FLINK + QUERY). This test currently asserts the view has exactly one representation, which will fail for backends that legitimately store more than one representation.



##########
flink-connector/flink-common/src/test/java/org/apache/gravitino/flink/connector/integration/test/FlinkCommonIT.java:
##########
@@ -812,4 +829,285 @@ && defaultValueWithNullLiterals()) {
       Assertions.assertEquals(expected[i].nullable(), actual[i].nullable());
     }
   }
+
+  @Test
+  @EnabledIf("supportViewOperation")
+  public void testCreateView() {
+    String schemaName = "test_create_view_db";
+    String viewName = "test_view_create";
+    String tableName = "test_view_base_table";
+    doWithSchema(
+        currentCatalog(),
+        schemaName,
+        catalog -> {
+          TestUtils.assertTableResult(
+              sql("CREATE TABLE %s (id INT, name STRING)%s", tableName, baseTableConnectorClause()),
+              ResultKind.SUCCESS);
+          TestUtils.assertTableResult(
+              sql(
+                  "CREATE VIEW %s COMMENT 'view comment' AS SELECT id, name FROM %s",
+                  viewName, tableName),
+              ResultKind.SUCCESS);
+
+          ViewCatalog viewCatalog = catalog.asViewCatalog();
+          View view = viewCatalog.loadView(NameIdentifier.of(schemaName, viewName));
+          Assertions.assertEquals(viewName, view.name());
+          Assertions.assertEquals("view comment", view.comment());
+          Assertions.assertEquals(1, view.representations().length);
+          Assertions.assertInstanceOf(SQLRepresentation.class, view.representations()[0]);
+
+          Optional<org.apache.flink.table.catalog.Catalog> flinkCatalog =
+              tableEnv.getCatalog(catalog.name());
+          Assertions.assertTrue(flinkCatalog.isPresent());
+          try {
+            CatalogBaseTable flinkTable =
+                flinkCatalog.get().getTable(new ObjectPath(schemaName, viewName));
+            Assertions.assertEquals(CatalogBaseTable.TableKind.VIEW, flinkTable.getTableKind());
+          } catch (TableNotExistException e) {
+            Assertions.fail("view should exist in Flink catalog: " + e.getMessage());
+          }
+        },
+        true,
+        supportDropCascade());
+  }
+
+  @Test
+  @EnabledIf("supportViewOperation")
+  public void testListViews() {
+    String schemaName = "test_list_views_db";
+    String tableName = "test_list_view_base";
+    String view1 = "test_list_view_1";
+    String view2 = "test_list_view_2";
+    doWithSchema(
+        currentCatalog(),
+        schemaName,
+        catalog -> {
+          TestUtils.assertTableResult(
+              sql("CREATE TABLE %s (id INT)%s", tableName, baseTableConnectorClause()),
+              ResultKind.SUCCESS);
+          TestUtils.assertTableResult(
+              sql("CREATE VIEW %s AS SELECT id FROM %s", view1, tableName), ResultKind.SUCCESS);
+          TestUtils.assertTableResult(
+              sql("CREATE VIEW %s AS SELECT id FROM %s", view2, tableName), ResultKind.SUCCESS);
+
+          List<String> views = Arrays.asList(tableEnv.listViews());
+          Assertions.assertTrue(views.contains(view1), "view1 not found in SHOW VIEWS");
+          Assertions.assertTrue(views.contains(view2), "view2 not found in SHOW VIEWS");
+          Assertions.assertFalse(views.contains(tableName), "table should not appear in listViews");
+
+          ViewCatalog viewCatalog = catalog.asViewCatalog();
+          NameIdentifier[] gravitinoViews = viewCatalog.listViews(Namespace.of(schemaName));
+          List<String> gravitinoViewNames =
+              Arrays.stream(gravitinoViews).map(NameIdentifier::name).collect(Collectors.toList());
+          Assertions.assertTrue(gravitinoViewNames.contains(view1));
+          Assertions.assertTrue(gravitinoViewNames.contains(view2));
+        },
+        true,
+        supportDropCascade());
+  }
+
+  @Test
+  @EnabledIf("supportViewOperation")
+  public void testDropView() {
+    String schemaName = "test_drop_view_db";
+    String tableName = "test_drop_view_base";
+    String viewName = "test_view_drop";
+    doWithSchema(
+        currentCatalog(),
+        schemaName,
+        catalog -> {
+          TestUtils.assertTableResult(
+              sql("CREATE TABLE %s (id INT)%s", tableName, baseTableConnectorClause()),
+              ResultKind.SUCCESS);
+          TestUtils.assertTableResult(
+              sql("CREATE VIEW %s AS SELECT id FROM %s", viewName, tableName), ResultKind.SUCCESS);
+
+          ViewCatalog viewCatalog = catalog.asViewCatalog();
+          Assertions.assertTrue(
+              viewCatalog.viewExists(NameIdentifier.of(schemaName, viewName)),
+              "view should exist before drop");
+
+          TestUtils.assertTableResult(sql("DROP VIEW %s", viewName), ResultKind.SUCCESS);
+
+          Assertions.assertFalse(
+              viewCatalog.viewExists(NameIdentifier.of(schemaName, viewName)),
+              "view should not exist after drop");
+        },
+        true,
+        supportDropCascade());
+  }
+
+  @Test
+  @EnabledIf("supportViewOperation")
+  public void testAlterViewRename() {
+    String schemaName = "test_rename_view_db";
+    String tableName = "test_rename_view_base";
+    String viewName = "test_view_rename_src";
+    String newViewName = "test_view_rename_dst";
+    doWithSchema(
+        currentCatalog(),
+        schemaName,
+        catalog -> {
+          TestUtils.assertTableResult(
+              sql("CREATE TABLE %s (id INT)%s", tableName, baseTableConnectorClause()),
+              ResultKind.SUCCESS);
+          TestUtils.assertTableResult(
+              sql("CREATE VIEW %s AS SELECT id FROM %s", viewName, tableName), ResultKind.SUCCESS);
+
+          TestUtils.assertTableResult(
+              sql("ALTER VIEW %s RENAME TO %s", viewName, newViewName), ResultKind.SUCCESS);
+
+          ViewCatalog viewCatalog = catalog.asViewCatalog();
+          Assertions.assertFalse(
+              viewCatalog.viewExists(NameIdentifier.of(schemaName, viewName)),
+              "old view name should not exist");
+          Assertions.assertTrue(
+              viewCatalog.viewExists(NameIdentifier.of(schemaName, newViewName)),
+              "new view name should exist");
+        },
+        true,
+        supportDropCascade());
+  }
+
+  @Test
+  @EnabledIf("supportViewOperation")
+  public void testAlterViewReplaceBody() {
+    String schemaName = "test_replace_view_db";
+    String tableName = "test_replace_view_base";
+    String viewName = "test_view_replace";
+    doWithSchema(
+        currentCatalog(),
+        schemaName,
+        catalog -> {
+          TestUtils.assertTableResult(
+              sql("CREATE TABLE %s (id INT, name STRING)%s", tableName, baseTableConnectorClause()),
+              ResultKind.SUCCESS);
+          TestUtils.assertTableResult(
+              sql("CREATE VIEW %s AS SELECT id FROM %s", viewName, tableName), ResultKind.SUCCESS);
+
+          TestUtils.assertTableResult(
+              sql("ALTER VIEW %s AS SELECT id, name FROM %s", viewName, tableName),
+              ResultKind.SUCCESS);
+
+          ViewCatalog viewCatalog = catalog.asViewCatalog();
+          View view = viewCatalog.loadView(NameIdentifier.of(schemaName, viewName));
+          Assertions.assertEquals(1, view.representations().length);
+          SQLRepresentation rep = (SQLRepresentation) view.representations()[0];
+          Assertions.assertTrue(

Review Comment:
   `GravitinoPaimonCatalog` can return multiple SQL representations for a view (FLINK + QUERY). This test assumes there is exactly one representation and casts the first element without checking, which can cause failures when additional representations are present.



##########
flink-connector/flink-common/src/test/java/org/apache/gravitino/flink/connector/integration/test/paimon/FlinkPaimonJdbcBackendIT.java:
##########
@@ -94,4 +94,10 @@ protected Map<String, String> getPaimonCatalogOptions() {
   protected String getWarehouse() {
     return warehouseDir.toString();
   }
+
+  @Override
+  protected boolean supportViewOperation() {
+    // Paimon JDBC metastore backend does not support view operations.
+    return false;
+  }

Review Comment:
   This class disables view tests for the Paimon JDBC backend (`supportViewOperation()` returns false), but the PR description/issue explicitly states view support (and tests) should be enabled for the Paimon JDBC backend. Either the implementation should support views for JDBC, or the PR description/issue linkage should be updated to reflect that JDBC is intentionally excluded.



-- 
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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org