You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/07/31 03:28:54 UTC

[GitHub] [flink] luoyuxia commented on a diff in pull request #20000: [FLINK-28096][hive] Hive dialect support set variables

luoyuxia commented on code in PR #20000:
URL: https://github.com/apache/flink/pull/20000#discussion_r933919454


##########
flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/connectors/hive/HiveDialectITCase.java:
##########
@@ -918,6 +918,72 @@ public void testMacro() throws Exception {
                         badMacroName);
     }
 
+    @Test
+    public void testSetCommand() throws Exception {
+        // test set system:
+        tableEnv.executeSql("set system:xxx=5");
+        assertThat(System.getProperty("xxx")).isEqualTo("5");
+
+        // test set hiveconf:
+        tableEnv.executeSql("set hiveconf:yyy=${system:xxx}");
+        assertThat(hiveCatalog.getHiveConf().get("yyy")).isEqualTo("5");
+
+        // test set hivevar:
+        tableEnv.executeSql("set hivevar:a=1");
+        tableEnv.executeSql("set hiveconf:zzz=${hivevar:a}");
+        assertThat(hiveCatalog.getHiveConf().get("zzz")).isEqualTo("1");
+
+        // test the hivevar still exists when we renew the sql parser
+        tableEnv.getConfig().setSqlDialect(SqlDialect.DEFAULT);
+        tableEnv.executeSql("show tables");
+        tableEnv.getConfig().setSqlDialect(SqlDialect.HIVE);
+        tableEnv.executeSql("set hiveconf:zzz1=${hivevar:a}");

Review Comment:
   1: We maynot use `set` statement to switch dialect directly for the `SetOperation` is executed in SqlClient.
   2: The Flink's `SetOperation` will be executed in SqlClient , so we can't set it in tableEnv. But the test [set.q](https://github.com/apache/flink/blob/master/flink-table/flink-sql-client/src/test/resources/sql/set.q) in flink-sql-client has covered the case that set flink config in HiveDialect.



-- 
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: issues-unsubscribe@flink.apache.org

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