Shekharrajak commented on code in PR #28789:
URL: https://github.com/apache/flink/pull/28789#discussion_r4193108455


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/runtime/common/sql/ConnectionITCase.java:
##########
@@ -76,11 +88,87 @@ void testCreateTemporaryConnectionRejectsDuplicate() {
 
     @Test
     void testCreatePermanentConnectionRejectedWithoutSecretStore() {
-        assertThatThrownBy(() -> tEnv().executeSql("CREATE CONNECTION my_conn 
WITH ('k' = 'v')"))
+        assertThatThrownBy(() -> tEnv.executeSql("CREATE CONNECTION my_conn 
WITH ('k' = 'v')"))
                 .isInstanceOf(ValidationException.class)
                 .hasMessageContaining("WritableSecretStore must be 
configured");
     }
 
+    @Test
+    void testDropTemporaryConnection() {
+        tEnv.executeSql("CREATE TEMPORARY CONNECTION my_conn WITH ('k' = 
'v')");
+
+        
assertThat(catalogManager().getConnection(connectionIdentifier("my_conn"))).isPresent();
+
+        tEnv.executeSql("DROP TEMPORARY CONNECTION my_conn");
+
+        
assertThat(catalogManager().getConnection(connectionIdentifier("my_conn"))).isEmpty();
+    }
+
+    @Test
+    void testDropTemporaryConnectionIfExists() {
+        tEnv.executeSql("DROP TEMPORARY CONNECTION IF EXISTS my_conn");
+
+        
assertThat(catalogManager().getConnection(connectionIdentifier("my_conn"))).isEmpty();
+    }
+
+    @Test
+    void testDropMissingTemporaryConnectionRejected() {
+        assertThatThrownBy(() -> tEnv.executeSql("DROP TEMPORARY CONNECTION 
my_conn"))
+                .isInstanceOf(ValidationException.class)
+                .hasMessage(
+                        "Temporary connection with identifier '%s' does not 
exist.",
+                        connectionIdentifier("my_conn").asSummaryString());
+    }
+
+    @Test
+    void testDropPermanentConnection() throws Exception {
+        ObjectIdentifier identifier = connectionIdentifier("my_conn");
+        catalogManager()
+                .getCatalog(identifier.getCatalogName())
+                .orElseThrow()
+                .createConnection(
+                        identifier.toObjectPath(),
+                        CatalogConnection.of(Map.of("k", "v"), null),
+                        false);
+        assertThat(catalogManager().getConnection(identifier)).isPresent();
+
+        tEnv.executeSql("DROP CONNECTION my_conn");
+
+        assertThat(catalogManager().getConnection(identifier)).isEmpty();
+    }
+
+    @Test
+    void testDropPermanentConnectionIfExists() {
+        tEnv.executeSql("DROP CONNECTION IF EXISTS my_conn");
+
+        
assertThat(catalogManager().getConnection(connectionIdentifier("my_conn"))).isEmpty();
+    }
+
+    @Test
+    void testDropMissingPermanentConnectionRejected() {
+        assertThatThrownBy(() -> tEnv.executeSql("DROP CONNECTION my_conn"))
+                .isInstanceOf(ValidationException.class)
+                .hasMessage(
+                        "Connection with identifier '%s' does not exist.",
+                        connectionIdentifier("my_conn").asSummaryString());
+    }
+
+    @Test
+    void testDropTemporarySystemConnectionRejected() {
+        tEnv.executeSql("CREATE TEMPORARY CONNECTION my_conn WITH ('k' = 
'v')");
+
+        for (String statement :
+                List.of(
+                        "DROP TEMPORARY SYSTEM CONNECTION my_conn",
+                        "DROP TEMPORARY SYSTEM CONNECTION IF EXISTS my_conn",
+                        "DROP TEMPORARY SYSTEM CONNECTION IF EXISTS 
missing_conn")) {
+            assertThatThrownBy(() -> tEnv.executeSql(statement))
+                    .isInstanceOf(ValidationException.class)
+                    .hasMessageContaining("DROP TEMPORARY SYSTEM CONNECTION is 
not supported");

Review Comment:
   Ack. I do review the code changes. 
   
   Actually this is to test droping system connection is not supported : 
https://github.com/apache/flink/pull/28789/changes#diff-7cc1e6a0f6d61e7cb428cc291044928820ddaac539aca82e434aa39afcb3c621R85
 
   
   with & without  `IF EXISTS` and `IF EXISTS` with some connection name also 
should through same error. 



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