Timm0 commented on code in PR #29973:
URL: https://github.com/apache/flink/pull/29973#discussion_r4600771119


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/runtime/stream/sql/MaterializedTableTableApiITCase.java:
##########
@@ -408,6 +411,57 @@ void testCreateMaterializedTableFailedInContinuousMode() {
         assertThat(catalog.tableExists(USERS_SHOPS.toObjectPath())).isFalse();
     }
 
+    @Test
+    void testRegularTableAndViewAtThePathAreRejected() throws Exception {
+        tEnv.createTable(
+                "existing_table",
+                TableDescriptor.forConnector("datagen")
+                        .schema(Schema.newBuilder().column("id", 
DataTypes.BIGINT()).build())
+                        .build());
+        tEnv.createView("existing_view", tEnv.from("datagenSource"));
+        final Set<JobID> jobsBefore = listJobIds();
+
+        assertThatThrownBy(
+                        () ->
+                                usersShopsQuery()
+                                        .materializeInto("existing_table")
+                                        .execute(CreateMode.failIfExists()))
+                .isInstanceOf(ValidationException.class)
+                .extracting(FlinkAssertions::chainOfCauses, 
FlinkAssertions.STREAM_THROWABLE)
+                .extracting(Throwable::getMessage)
+                .containsExactly(
+                        "Could not execute CreateTable in path 
`test_catalog`.`test_db`.`existing_table`",
+                        "Table (or view) test_db.existing_table already exists 
in Catalog test_catalog.");
+        assertThatThrownBy(
+                        () ->
+                                usersShopsQuery()
+                                        .materializeInto("existing_view")
+                                        .execute(CreateMode.failIfExists()))
+                .isInstanceOf(ValidationException.class)
+                .extracting(FlinkAssertions::chainOfCauses, 
FlinkAssertions.STREAM_THROWABLE)
+                .extracting(Throwable::getMessage)
+                .containsExactly(
+                        "Could not execute CreateTable in path 
`test_catalog`.`test_db`.`existing_view`",
+                        "Table (or view) test_db.existing_view already exists 
in Catalog test_catalog.");
+        // A regular table under createOrAlter() is rejected before planning.

Review Comment:
   Done.



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