Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3072,6 +3072,11 @@ void parseJoinCondPopulateAlias(QBJoinTree joinTree, ASTNode condn,

if (rightAliases.size() > rhssize) { // the new table is rhs table
rhsAlias = rightAliases.get(rightAliases.size() - 1);
} else if (condn.getChild(0).getType() == HiveParser.TOK_TABLE_OR_COL) {
String alias = unescapeIdentifier(condn.getChild(0).getChild(0).getText().toLowerCase());
if (isPresent(joinTree.getRightAliases(), alias)) {
rhsAlias = alias;
}
}

parseJoinCondPopulateAlias(joinTree, (ASTNode) condn.getChild(1),
Expand Down
8 changes: 8 additions & 0 deletions ql/src/test/queries/clientpositive/join_common_rhs_alias.q
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CREATE TABLE tab (c1 STRING, c2 STRING, c3 STRING);

INSERT INTO tab VALUES("a", "a", "aa"), ("b", "b", "ba"), ("c", "c" , "a");

SELECT t1.* FROM tab t1 LEFT OUTER JOIN tab t2
ON t1.c1 == t2.c1
AND CONCAT ( t1.c2 , 'a') = CONCAT ( t2.c2 , t2.c3 )
WHERE t2.c1 IS NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
PREHOOK: query: CREATE TABLE tab (c1 STRING, c2 STRING, c3 STRING)
PREHOOK: type: CREATETABLE
PREHOOK: Output: database:default
PREHOOK: Output: default@tab
POSTHOOK: query: CREATE TABLE tab (c1 STRING, c2 STRING, c3 STRING)
POSTHOOK: type: CREATETABLE
POSTHOOK: Output: database:default
POSTHOOK: Output: default@tab
PREHOOK: query: INSERT INTO tab VALUES("a", "a", "aa"), ("b", "b", "ba"), ("c", "c" , "a")
PREHOOK: type: QUERY
PREHOOK: Input: _dummy_database@_dummy_table
PREHOOK: Output: default@tab
POSTHOOK: query: INSERT INTO tab VALUES("a", "a", "aa"), ("b", "b", "ba"), ("c", "c" , "a")
POSTHOOK: type: QUERY
POSTHOOK: Input: _dummy_database@_dummy_table
POSTHOOK: Output: default@tab
POSTHOOK: Lineage: tab.c1 SCRIPT []
POSTHOOK: Lineage: tab.c2 SCRIPT []
POSTHOOK: Lineage: tab.c3 SCRIPT []
PREHOOK: query: SELECT t1.* FROM tab t1 LEFT OUTER JOIN tab t2
ON t1.c1 == t2.c1
AND CONCAT ( t1.c2 , 'a') = CONCAT ( t2.c2 , t2.c3 )
WHERE t2.c1 IS NULL
PREHOOK: type: QUERY
PREHOOK: Input: default@tab
#### A masked pattern was here ####
POSTHOOK: query: SELECT t1.* FROM tab t1 LEFT OUTER JOIN tab t2
ON t1.c1 == t2.c1
AND CONCAT ( t1.c2 , 'a') = CONCAT ( t2.c2 , t2.c3 )
WHERE t2.c1 IS NULL
POSTHOOK: type: QUERY
POSTHOOK: Input: default@tab
#### A masked pattern was here ####
a a aa
b b ba
10 changes: 5 additions & 5 deletions ql/src/test/results/clientpositive/llap/semijoin6.q.out
Original file line number Diff line number Diff line change
Expand Up @@ -777,20 +777,20 @@ STAGE PLANS:
Statistics: Num rows: 6 Data size: 48 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
expressions: a (type: int), b (type: int)
outputColumnNames: _col0, _col2
outputColumnNames: _col0, _col3
Statistics: Num rows: 6 Data size: 48 Basic stats: COMPLETE Column stats: COMPLETE
Group By Operator
keys: _col0 (type: int), _col2 (type: int), _col2 (type: int)
keys: _col0 (type: int), _col3 (type: int), _col3 (type: int), _col3 (type: int)
minReductionHashAggr: 0.4
mode: hash
outputColumnNames: _col0, _col1, _col2
Statistics: Num rows: 5 Data size: 60 Basic stats: COMPLETE Column stats: COMPLETE
outputColumnNames: _col0, _col1, _col2, _col3
Statistics: Num rows: 5 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
Reduce Output Operator
key expressions: _col0 (type: int)
null sort order: z
sort order: +
Map-reduce partition columns: _col0 (type: int)
Statistics: Num rows: 5 Data size: 60 Basic stats: COMPLETE Column stats: COMPLETE
Statistics: Num rows: 5 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
value expressions: _col1 (type: int)
Execution mode: vectorized, llap
LLAP IO: all inputs
Expand Down