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/05/09 06:59:40 UTC

[GitHub] [flink] Tartarus0zm commented on a diff in pull request #19656: [FLINK-26371][hive] Support variable substitution for sql statement while using Hive dialect

Tartarus0zm commented on code in PR #19656:
URL: https://github.com/apache/flink/pull/19656#discussion_r867688723


##########
flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/connectors/hive/HiveDialectITCase.java:
##########
@@ -807,6 +807,29 @@ public void testShowPartitions() throws Exception {
         assertTrue(partitions.toString().contains("dt=2020-04-30 01:02:03/country=china"));
     }
 
+    @Test
+    public void testStatementVariableSubstitution() {
+        // test system variable for substitution
+        System.setProperty("k1", "v1");
+        List<Row> result =
+                CollectionUtil.iteratorToList(
+                        tableEnv.executeSql("select '${system:k1}'").collect());
+        assertEquals("[+I[v1]]", result.toString());
+
+        // test env variable for substitution
+        String classPath = System.getenv("CLASSPATH");

Review Comment:
   env `CLASSPATH ` maybe not exist.
   We should test for an environment variable that exists and an environment variable that does not exist



##########
flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/connectors/hive/HiveDialectITCase.java:
##########
@@ -807,6 +807,29 @@ public void testShowPartitions() throws Exception {
         assertTrue(partitions.toString().contains("dt=2020-04-30 01:02:03/country=china"));
     }
 
+    @Test
+    public void testStatementVariableSubstitution() {
+        // test system variable for substitution
+        System.setProperty("k1", "v1");
+        List<Row> result =
+                CollectionUtil.iteratorToList(
+                        tableEnv.executeSql("select '${system:k1}'").collect());
+        assertEquals("[+I[v1]]", result.toString());
+
+        // test env variable for substitution
+        String classPath = System.getenv("CLASSPATH");
+        result =
+                CollectionUtil.iteratorToList(
+                        tableEnv.executeSql("select '${env:CLASSPATH}'").collect());
+        assertEquals(String.format("[+I[%s]]", classPath), result.toString());
+
+        // test hive conf variable for substitution
+        result =
+                CollectionUtil.iteratorToList(
+                        tableEnv.executeSql("select '${hiveconf:common-key}'").collect());

Review Comment:
   How do users dynamically set hiveconf variables in the flink table api? `common-key` is a variable that exists in the test hive-site.xml



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