Repository: hive Updated Branches: refs/heads/master 28db173b9 -> a3aa074d7
HIVE-21113: For HPL/SQL that contains boolean expression with NOT, incorrect SQL may be generated (Baoning He, reviewed by Daniel Dai) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/a3aa074d Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/a3aa074d Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/a3aa074d Branch: refs/heads/master Commit: a3aa074d7b27b3c6037ee1c0f6afb03044983c92 Parents: 28db173 Author: Daniel Dai <dai...@gmail.com> Authored: Fri Jan 11 16:36:01 2019 -0800 Committer: Daniel Dai <dai...@gmail.com> Committed: Fri Jan 11 16:36:01 2019 -0800 ---------------------------------------------------------------------- hplsql/src/main/java/org/apache/hive/hplsql/Expression.java | 3 +++ hplsql/src/test/queries/offline/select.sql | 6 +++++- hplsql/src/test/results/offline/select.out.txt | 7 ++++++- 3 files changed, 14 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/a3aa074d/hplsql/src/main/java/org/apache/hive/hplsql/Expression.java ---------------------------------------------------------------------- diff --git a/hplsql/src/main/java/org/apache/hive/hplsql/Expression.java b/hplsql/src/main/java/org/apache/hive/hplsql/Expression.java index 188b173..1002581 100644 --- a/hplsql/src/main/java/org/apache/hive/hplsql/Expression.java +++ b/hplsql/src/main/java/org/apache/hive/hplsql/Expression.java @@ -148,6 +148,9 @@ public class Expression { public void execBoolSql(HplsqlParser.Bool_exprContext ctx) { StringBuilder sql = new StringBuilder(); if (ctx.T_OPEN_P() != null) { + if (ctx.T_NOT() != null) { + sql.append(ctx.T_NOT().getText() + " "); + } sql.append("("); sql.append(evalPop(ctx.bool_expr(0)).toString()); sql.append(")"); http://git-wip-us.apache.org/repos/asf/hive/blob/a3aa074d/hplsql/src/test/queries/offline/select.sql ---------------------------------------------------------------------- diff --git a/hplsql/src/test/queries/offline/select.sql b/hplsql/src/test/queries/offline/select.sql index 0b6912e..cd5a233 100644 --- a/hplsql/src/test/queries/offline/select.sql +++ b/hplsql/src/test/queries/offline/select.sql @@ -39,4 +39,8 @@ FROM LEFT OUTER JOIN TEST.LOCATION LOC ON DLTA_POC.SE_KEY_POC = LOC.LOC_ID - AND LOC.LOCATION_END_DT = DATE '9999-12-31' ; \ No newline at end of file + AND LOC.LOCATION_END_DT = DATE '9999-12-31' ; + +SELECT * + FROM a + WHERE NOT (1 = 2) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/hive/blob/a3aa074d/hplsql/src/test/results/offline/select.out.txt ---------------------------------------------------------------------- diff --git a/hplsql/src/test/results/offline/select.out.txt b/hplsql/src/test/results/offline/select.out.txt index 529f0b5..849a1ea 100644 --- a/hplsql/src/test/results/offline/select.out.txt +++ b/hplsql/src/test/results/offline/select.out.txt @@ -31,4 +31,9 @@ FROM DLTA_POC LEFT OUTER JOIN TEST3_DB.TET ORG ON DLTA_POC.YS_NO = ORG.EM_CODE_A AND DLTA_POC.AREA_NO = ORG.AREA_CODE_2 AND DLTA_POC.GNT_POC = ORG.GEN_CD LEFT OUTER JOIN TEST.LOCATION LOC ON DLTA_POC.SE_KEY_POC = LOC.LOC_ID AND LOC.LOCATION_END_DT = DATE '9999-12-31' -Ln:31 Not executed - offline mode set \ No newline at end of file +Ln:31 Not executed - offline mode set +Ln:44 SELECT +Ln:44 SELECT * + FROM a + WHERE NOT (1 = 2) +Ln:44 Not executed - offline mode set \ No newline at end of file