hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jcama...@apache.org
Subject hive git commit: HIVE-14022: left semi join should throw SemanticException if where clause contains columnname from right table (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)
Date Fri, 17 Jun 2016 16:18:31 GMT
Repository: hive
Updated Branches:
  refs/heads/master f65739523 -> 7363d400a


HIVE-14022: left semi join should throw SemanticException if where clause contains columnname
from right table (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/7363d400
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/7363d400
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/7363d400

Branch: refs/heads/master
Commit: 7363d400a89a89000a66c0bb4a68c4177914517e
Parents: f657395
Author: Jesus Camacho Rodriguez <jcamacho@apache.org>
Authored: Fri Jun 17 17:15:48 2016 +0100
Committer: Jesus Camacho Rodriguez <jcamacho@apache.org>
Committed: Fri Jun 17 17:17:48 2016 +0100

----------------------------------------------------------------------
 .../hadoop/hive/ql/parse/SemanticAnalyzer.java  |  4 ++++
 ql/src/test/queries/clientnegative/semijoin5.q  |  6 +++++
 .../test/results/clientnegative/semijoin5.q.out | 25 ++++++++++++++++++++
 3 files changed, 35 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/7363d400/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
index cd3c860..774cc2b 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
@@ -2449,6 +2449,10 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
           if (!rightAliases.contains(tableOrCol)) {
             rightAliases.add(tableOrCol);
           }
+          if (joinTree.getNoSemiJoin() == false) {
+            // if this is a semijoin, we need to add the condition
+            joinTree.addRHSSemijoinColumns(tableOrCol, condn);
+          }
         }
       }
       break;

http://git-wip-us.apache.org/repos/asf/hive/blob/7363d400/ql/src/test/queries/clientnegative/semijoin5.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/semijoin5.q b/ql/src/test/queries/clientnegative/semijoin5.q
new file mode 100644
index 0000000..f805604
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/semijoin5.q
@@ -0,0 +1,6 @@
+create table t1 as select cast(key as int) key, value from src where key <= 10;
+
+create table t5 as select cast(key as int) key1, value value1 from src where key <= 100;
+
+-- reference rhs of semijoin in where-clause
+explain select * from t1 left semi join t5 on value = value1 where key = 100 and key1 = 100;

http://git-wip-us.apache.org/repos/asf/hive/blob/7363d400/ql/src/test/results/clientnegative/semijoin5.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/semijoin5.q.out b/ql/src/test/results/clientnegative/semijoin5.q.out
new file mode 100644
index 0000000..d4fd728
--- /dev/null
+++ b/ql/src/test/results/clientnegative/semijoin5.q.out
@@ -0,0 +1,25 @@
+PREHOOK: query: create table t1 as select cast(key as int) key, value from src where key
<= 10
+PREHOOK: type: CREATETABLE_AS_SELECT
+PREHOOK: Input: default@src
+PREHOOK: Output: database:default
+PREHOOK: Output: default@t1
+POSTHOOK: query: create table t1 as select cast(key as int) key, value from src where key
<= 10
+POSTHOOK: type: CREATETABLE_AS_SELECT
+POSTHOOK: Input: default@src
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@t1
+POSTHOOK: Lineage: t1.key EXPRESSION [(src)src.FieldSchema(name:key, type:string, comment:default),
]
+POSTHOOK: Lineage: t1.value SIMPLE [(src)src.FieldSchema(name:value, type:string, comment:default),
]
+PREHOOK: query: create table t5 as select cast(key as int) key1, value value1 from src where
key <= 100
+PREHOOK: type: CREATETABLE_AS_SELECT
+PREHOOK: Input: default@src
+PREHOOK: Output: database:default
+PREHOOK: Output: default@t5
+POSTHOOK: query: create table t5 as select cast(key as int) key1, value value1 from src where
key <= 100
+POSTHOOK: type: CREATETABLE_AS_SELECT
+POSTHOOK: Input: default@src
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@t5
+POSTHOOK: Lineage: t5.key1 EXPRESSION [(src)src.FieldSchema(name:key, type:string, comment:default),
]
+POSTHOOK: Lineage: t5.value1 SIMPLE [(src)src.FieldSchema(name:value, type:string, comment:default),
]
+FAILED: SemanticException [Error 10004]: Line 4:81 Invalid table alias or column reference
'key1': (possible column names are: key, value)


Mime
View raw message