diff --git hplsql/src/main/java/org/apache/hive/hplsql/Exec.java hplsql/src/main/java/org/apache/hive/hplsql/Exec.java index 2ad3ea3..b0a7849 100644 --- hplsql/src/main/java/org/apache/hive/hplsql/Exec.java +++ hplsql/src/main/java/org/apache/hive/hplsql/Exec.java @@ -2145,7 +2145,14 @@ public Integer visitIdent(HplsqlParser.IdentContext ctx) { return 0; } else { - exec.stackPush(new Var(Var.Type.IDENT, ident)); + // If identifier is double quoted convert it to the string as here it is neither + // variable nor column + if (ident.charAt(0) == '"') { + exec.stackPush(new Var(ident, Var.Type.STRING, ident.substring(1, ident.length()-1))); + } + else { + exec.stackPush(new Var(Var.Type.IDENT, ident)); + } } } return 0; diff --git hplsql/src/test/java/org/apache/hive/hplsql/TestHplsqlLocal.java hplsql/src/test/java/org/apache/hive/hplsql/TestHplsqlLocal.java index 8692661..160ea21 100644 --- hplsql/src/test/java/org/apache/hive/hplsql/TestHplsqlLocal.java +++ hplsql/src/test/java/org/apache/hive/hplsql/TestHplsqlLocal.java @@ -298,6 +298,11 @@ public void testPrint() throws Exception { } @Test + public void testQuotes() throws Exception { + run("quotes"); + } + + @Test public void testReplace() throws Exception { run("replace"); } diff --git hplsql/src/test/queries/local/quotes.sql hplsql/src/test/queries/local/quotes.sql new file mode 100644 index 0000000..3748e23 --- /dev/null +++ hplsql/src/test/queries/local/quotes.sql @@ -0,0 +1,10 @@ +DECLARE val string; + +val := 'VALUE IS SET'; +print(val); + +val := "VALUE IS SET"; +print(val); + +val := SOME_UNKNOWN_IDENT; +print(val); \ No newline at end of file diff --git hplsql/src/test/results/local/create_package3.out.txt hplsql/src/test/results/local/create_package3.out.txt index f8cafaa..929ba6a 100644 --- hplsql/src/test/results/local/create_package3.out.txt +++ hplsql/src/test/results/local/create_package3.out.txt @@ -2,4 +2,4 @@ Ln:1 INCLUDE src/test/queries/local/create_package3_include.sql INCLUDE CONTENT src/test/queries/local/create_package3_include.sql (non-empty) EXEC PACKAGE PROCEDURE A.test Ln:9 PRINT -"test ok" \ No newline at end of file +test ok \ No newline at end of file diff --git hplsql/src/test/results/local/quotes.out.txt hplsql/src/test/results/local/quotes.out.txt new file mode 100644 index 0000000..69fd80f --- /dev/null +++ hplsql/src/test/results/local/quotes.out.txt @@ -0,0 +1,10 @@ +Ln:1 DECLARE val string +Ln:3 SET val = 'VALUE IS SET' +Ln:4 PRINT +VALUE IS SET +Ln:6 SET val = 'VALUE IS SET' +Ln:7 PRINT +VALUE IS SET +Ln:9 SET val = NULL +Ln:10 PRINT +null \ No newline at end of file