You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by jp...@apache.org on 2015/02/09 19:07:03 UTC
svn commit: r1658489 [1/6] - in /hive/trunk: itests/src/test/resources/
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/
ql/src/java/org/apache/hadoop/hive/ql/parse/
ql/src/test/queries/clientnegative/ ql/src/test/queries/clientposit...
Author: jpullokk
Date: Mon Feb 9 18:07:01 2015
New Revision: 1658489
URL: http://svn.apache.org/r1658489
Log:
HIVE-9039: Support Union Distinct (Pengcheng Xiong via Laljo John Pullokkaran)
Added:
hive/trunk/ql/src/test/queries/clientnegative/unionClusterBy.q
hive/trunk/ql/src/test/queries/clientnegative/unionDistributeBy.q
hive/trunk/ql/src/test/queries/clientnegative/unionLimit.q
hive/trunk/ql/src/test/queries/clientnegative/unionOrderBy.q
hive/trunk/ql/src/test/queries/clientnegative/unionSortBy.q
hive/trunk/ql/src/test/queries/clientpositive/unionDistinct_1.q
hive/trunk/ql/src/test/queries/clientpositive/unionDistinct_2.q
hive/trunk/ql/src/test/results/clientnegative/unionClusterBy.q.out
hive/trunk/ql/src/test/results/clientnegative/unionDistributeBy.q.out
hive/trunk/ql/src/test/results/clientnegative/unionLimit.q.out
hive/trunk/ql/src/test/results/clientnegative/unionOrderBy.q.out
hive/trunk/ql/src/test/results/clientnegative/unionSortBy.q.out
hive/trunk/ql/src/test/results/clientpositive/tez/unionDistinct_1.q.out
hive/trunk/ql/src/test/results/clientpositive/tez/unionDistinct_2.q.out
hive/trunk/ql/src/test/results/clientpositive/unionDistinct_1.q.out
hive/trunk/ql/src/test/results/clientpositive/unionDistinct_2.q.out
Modified:
hive/trunk/itests/src/test/resources/testconfiguration.properties
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ASTConverter.java
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
hive/trunk/ql/src/test/queries/clientpositive/cbo_union.q
hive/trunk/ql/src/test/queries/clientpositive/explode_null.q
hive/trunk/ql/src/test/queries/clientpositive/input25.q
hive/trunk/ql/src/test/queries/clientpositive/input26.q
hive/trunk/ql/src/test/queries/clientpositive/load_dyn_part14.q
hive/trunk/ql/src/test/queries/clientpositive/metadataOnlyOptimizer.q
hive/trunk/ql/src/test/queries/clientpositive/script_env_var1.q
hive/trunk/ql/src/test/queries/clientpositive/script_env_var2.q
hive/trunk/ql/src/test/queries/clientpositive/union3.q
hive/trunk/ql/src/test/queries/clientpositive/union_null.q
hive/trunk/ql/src/test/queries/clientpositive/union_remove_25.q
hive/trunk/ql/src/test/queries/clientpositive/union_top_level.q
hive/trunk/ql/src/test/queries/clientpositive/vector_multi_insert.q
hive/trunk/ql/src/test/results/clientpositive/ba_table_union.q.out
hive/trunk/ql/src/test/results/clientpositive/cbo_union.q.out
hive/trunk/ql/src/test/results/clientpositive/char_union1.q.out
hive/trunk/ql/src/test/results/clientpositive/explain_logical.q.out
hive/trunk/ql/src/test/results/clientpositive/explode_null.q.out
hive/trunk/ql/src/test/results/clientpositive/groupby_sort_1_23.q.out
hive/trunk/ql/src/test/results/clientpositive/groupby_sort_skew_1_23.q.out
hive/trunk/ql/src/test/results/clientpositive/input25.q.out
hive/trunk/ql/src/test/results/clientpositive/input26.q.out
hive/trunk/ql/src/test/results/clientpositive/input_part7.q.out
hive/trunk/ql/src/test/results/clientpositive/join34.q.out
hive/trunk/ql/src/test/results/clientpositive/join35.q.out
hive/trunk/ql/src/test/results/clientpositive/load_dyn_part14.q.out
hive/trunk/ql/src/test/results/clientpositive/merge4.q.out
hive/trunk/ql/src/test/results/clientpositive/metadataOnlyOptimizer.q.out
hive/trunk/ql/src/test/results/clientpositive/optimize_nullscan.q.out
hive/trunk/ql/src/test/results/clientpositive/script_env_var1.q.out
hive/trunk/ql/src/test/results/clientpositive/script_env_var2.q.out
hive/trunk/ql/src/test/results/clientpositive/spark/groupby_sort_1_23.q.out
hive/trunk/ql/src/test/results/clientpositive/spark/groupby_sort_skew_1_23.q.out
hive/trunk/ql/src/test/results/clientpositive/spark/join34.q.out
hive/trunk/ql/src/test/results/clientpositive/spark/join35.q.out
hive/trunk/ql/src/test/results/clientpositive/spark/load_dyn_part14.q.out
hive/trunk/ql/src/test/results/clientpositive/spark/optimize_nullscan.q.out
hive/trunk/ql/src/test/results/clientpositive/spark/script_env_var1.q.out
hive/trunk/ql/src/test/results/clientpositive/spark/script_env_var2.q.out
hive/trunk/ql/src/test/results/clientpositive/spark/union3.q.out
hive/trunk/ql/src/test/results/clientpositive/spark/union_null.q.out
hive/trunk/ql/src/test/results/clientpositive/spark/union_ppr.q.out
hive/trunk/ql/src/test/results/clientpositive/spark/union_remove_25.q.out
hive/trunk/ql/src/test/results/clientpositive/tez/cbo_union.q.out
hive/trunk/ql/src/test/results/clientpositive/tez/optimize_nullscan.q.out
hive/trunk/ql/src/test/results/clientpositive/tez/script_env_var1.q.out
hive/trunk/ql/src/test/results/clientpositive/tez/script_env_var2.q.out
hive/trunk/ql/src/test/results/clientpositive/tez/union3.q.out
hive/trunk/ql/src/test/results/clientpositive/union22.q.out
hive/trunk/ql/src/test/results/clientpositive/union24.q.out
hive/trunk/ql/src/test/results/clientpositive/union3.q.out
hive/trunk/ql/src/test/results/clientpositive/union_null.q.out
hive/trunk/ql/src/test/results/clientpositive/union_ppr.q.out
hive/trunk/ql/src/test/results/clientpositive/union_remove_25.q.out
hive/trunk/ql/src/test/results/clientpositive/union_top_level.q.out
hive/trunk/ql/src/test/results/clientpositive/varchar_union1.q.out
hive/trunk/ql/src/test/results/clientpositive/vector_multi_insert.q.out
Modified: hive/trunk/itests/src/test/resources/testconfiguration.properties
URL: http://svn.apache.org/viewvc/hive/trunk/itests/src/test/resources/testconfiguration.properties?rev=1658489&r1=1658488&r2=1658489&view=diff
==============================================================================
--- hive/trunk/itests/src/test/resources/testconfiguration.properties (original)
+++ hive/trunk/itests/src/test/resources/testconfiguration.properties Mon Feb 9 18:07:01 2015
@@ -167,6 +167,8 @@ minitez.query.files.shared=alter_merge_2
union7.q,\
union8.q,\
union9.q,\
+ unionDistinct_1.q,\
+ unionDistinct_2.q,\
update_after_multiple_inserts.q,\
update_all_non_partitioned.q,\
update_all_partitioned.q,\
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ASTConverter.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ASTConverter.java?rev=1658489&r1=1658488&r2=1658489&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ASTConverter.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ASTConverter.java Mon Feb 9 18:07:01 2015
@@ -722,7 +722,7 @@ public class ASTConverter {
public ASTNode getUnionAllAST(ASTNode leftAST, ASTNode rightAST) {
- ASTNode unionTokAST = ASTBuilder.construct(HiveParser.TOK_UNION, "TOK_UNION").add(leftAST)
+ ASTNode unionTokAST = ASTBuilder.construct(HiveParser.TOK_UNIONALL, "TOK_UNIONALL").add(leftAST)
.add(rightAST).node();
return unionTokAST;
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g?rev=1658489&r1=1658488&r2=1658489&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g Mon Feb 9 18:07:01 2015
@@ -85,7 +85,8 @@ TOK_ORDERBY;
TOK_CLUSTERBY;
TOK_DISTRIBUTEBY;
TOK_SORTBY;
-TOK_UNION;
+TOK_UNIONALL;
+TOK_UNIONDISTINCT;
TOK_JOIN;
TOK_LEFTOUTERJOIN;
TOK_RIGHTOUTERJOIN;
@@ -612,10 +613,12 @@ import java.util.HashMap;
// counter to generate unique union aliases
private int aliasCounter;
-
private String generateUnionAlias() {
return "_u" + (++aliasCounter);
}
+ private CommonTree throwSetOpException() throws RecognitionException {
+ throw new FailedPredicateException(input, "orderByClause clusterByClause distributeByClause sortByClause limitClause can only be applied to the whole union.", "");
+ }
}
@rulecatch {
@@ -2043,7 +2046,8 @@ unionType
setOperator
@init { pushMsg("set operator", state); }
@after { popMsg(state); }
- : KW_UNION KW_ALL -> ^(TOK_UNION)
+ : KW_UNION KW_ALL -> ^(TOK_UNIONALL)
+ | KW_UNION KW_DISTINCT? -> ^(TOK_UNIONDISTINCT)
;
queryStatementExpression[boolean topLevel]
@@ -2131,41 +2135,98 @@ regularBody[boolean topLevel]
selectStatement[topLevel]
;
- selectStatement[boolean topLevel]
- : (singleSelectStatement -> singleSelectStatement)
- (u=setOperator b=singleSelectStatement
- -> ^($u {$selectStatement.tree} $b)
- )*
- -> {u != null && topLevel}? ^(TOK_QUERY
- ^(TOK_FROM
- ^(TOK_SUBQUERY
- {$selectStatement.tree}
+selectStatement[boolean topLevel]
+ :
+ (
+ s=selectClause
+ f=fromClause?
+ w=whereClause?
+ g=groupByClause?
+ h=havingClause?
+ o=orderByClause?
+ c=clusterByClause?
+ d=distributeByClause?
+ sort=sortByClause?
+ win=window_clause?
+ l=limitClause?
+ -> ^(TOK_QUERY $f? ^(TOK_INSERT ^(TOK_DESTINATION ^(TOK_DIR TOK_TMP_FILE))
+ $s $w? $g? $h? $o? $c?
+ $d? $sort? $win? $l?))
+ )
+ (set=setOpSelectStatement[$selectStatement.tree, topLevel])?
+ -> {set == null}?
+ {$selectStatement.tree}
+ -> {o==null && c==null && d==null && sort==null && l==null}?
+ {$set.tree}
+ -> {throwSetOpException()}
+ ;
+
+setOpSelectStatement[CommonTree t, boolean topLevel]
+ :
+ (u=setOperator b=simpleSelectStatement
+ -> {$setOpSelectStatement.tree != null && u.tree.getType()==HiveParser.TOK_UNIONDISTINCT}?
+ ^(TOK_QUERY
+ ^(TOK_FROM
+ ^(TOK_SUBQUERY
+ ^(TOK_UNIONALL {$setOpSelectStatement.tree} $b)
{adaptor.create(Identifier, generateUnionAlias())}
)
)
- ^(TOK_INSERT
+ ^(TOK_INSERT
+ ^(TOK_DESTINATION ^(TOK_DIR TOK_TMP_FILE))
+ ^(TOK_SELECTDI ^(TOK_SELEXPR TOK_ALLCOLREF))
+ )
+ )
+ -> {$setOpSelectStatement.tree != null && u.tree.getType()!=HiveParser.TOK_UNIONDISTINCT}?
+ ^(TOK_UNIONALL {$setOpSelectStatement.tree} $b)
+ -> {$setOpSelectStatement.tree == null && u.tree.getType()==HiveParser.TOK_UNIONDISTINCT}?
+ ^(TOK_QUERY
+ ^(TOK_FROM
+ ^(TOK_SUBQUERY
+ ^(TOK_UNIONALL {$t} $b)
+ {adaptor.create(Identifier, generateUnionAlias())}
+ )
+ )
+ ^(TOK_INSERT
^(TOK_DESTINATION ^(TOK_DIR TOK_TMP_FILE))
- ^(TOK_SELECT ^(TOK_SELEXPR TOK_ALLCOLREF))
+ ^(TOK_SELECTDI ^(TOK_SELEXPR TOK_ALLCOLREF))
+ )
+ )
+ -> ^(TOK_UNIONALL {$t} $b)
+ )+
+ o=orderByClause?
+ c=clusterByClause?
+ d=distributeByClause?
+ sort=sortByClause?
+ win=window_clause?
+ l=limitClause?
+ -> {o==null && c==null && d==null && sort==null && win==null && l==null && !topLevel}?
+ {$setOpSelectStatement.tree}
+ -> ^(TOK_QUERY
+ ^(TOK_FROM
+ ^(TOK_SUBQUERY
+ {$setOpSelectStatement.tree}
+ {adaptor.create(Identifier, generateUnionAlias())}
+ )
)
- )
- -> {$selectStatement.tree}
- ;
+ ^(TOK_INSERT
+ ^(TOK_DESTINATION ^(TOK_DIR TOK_TMP_FILE))
+ ^(TOK_SELECT ^(TOK_SELEXPR TOK_ALLCOLREF))
+ $o? $c? $d? $sort? $win? $l?
+ )
+ )
+ ;
-singleSelectStatement
+simpleSelectStatement
:
selectClause
fromClause?
whereClause?
groupByClause?
havingClause?
- orderByClause?
- clusterByClause?
- distributeByClause?
- sortByClause?
window_clause?
- limitClause? -> ^(TOK_QUERY fromClause? ^(TOK_INSERT ^(TOK_DESTINATION ^(TOK_DIR TOK_TMP_FILE))
- selectClause whereClause? groupByClause? havingClause? orderByClause? clusterByClause?
- distributeByClause? sortByClause? window_clause? limitClause?))
+ -> ^(TOK_QUERY fromClause? ^(TOK_INSERT ^(TOK_DESTINATION ^(TOK_DIR TOK_TMP_FILE))
+ selectClause whereClause? groupByClause? havingClause? window_clause?))
;
selectStatementWithCTE
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g?rev=1658489&r1=1658488&r2=1658489&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g Mon Feb 9 18:07:01 2015
@@ -572,5 +572,5 @@ principalIdentifier
nonReserved
:
- KW_TRUE | KW_FALSE | KW_LIKE | KW_EXISTS | KW_ASC | KW_DESC | KW_ORDER | KW_GROUP | KW_BY | KW_AS | KW_INSERT | KW_OVERWRITE | KW_OUTER | KW_LEFT | KW_RIGHT | KW_FULL | KW_PARTITION | KW_PARTITIONS | KW_TABLE | KW_TABLES | KW_COLUMNS | KW_INDEX | KW_INDEXES | KW_REBUILD | KW_FUNCTIONS | KW_SHOW | KW_MSCK | KW_REPAIR | KW_DIRECTORY | KW_LOCAL | KW_USING | KW_CLUSTER | KW_DISTRIBUTE | KW_SORT | KW_UNION | KW_LOAD | KW_EXPORT | KW_IMPORT | KW_DATA | KW_INPATH | KW_IS | KW_NULL | KW_CREATE | KW_EXTERNAL | KW_ALTER | KW_CHANGE | KW_FIRST | KW_AFTER | KW_DESCRIBE | KW_DROP | KW_RENAME | KW_IGNORE | KW_PROTECTION | KW_TO | KW_COMMENT | KW_BOOLEAN | KW_TINYINT | KW_SMALLINT | KW_INT | KW_BIGINT | KW_FLOAT | KW_DOUBLE | KW_DATE | KW_DATETIME | KW_TIMESTAMP | KW_DECIMAL | KW_STRING | KW_ARRAY | KW_STRUCT | KW_UNIONTYPE | KW_PARTITIONED | KW_CLUSTERED | KW_SORTED | KW_INTO | KW_BUCKETS | KW_ROW | KW_ROWS | KW_FORMAT | KW_DELIMITED | KW_FIELDS | KW_TERMINATED | KW_ESCAPED | KW_COLLECTION |
KW_ITEMS | KW_KEYS | KW_KEY_TYPE | KW_LINES | KW_STORED | KW_FILEFORMAT | KW_INPUTFORMAT | KW_OUTPUTFORMAT | KW_INPUTDRIVER | KW_OUTPUTDRIVER | KW_OFFLINE | KW_ENABLE | KW_DISABLE | KW_READONLY | KW_NO_DROP | KW_LOCATION | KW_BUCKET | KW_OUT | KW_OF | KW_PERCENT | KW_ADD | KW_REPLACE | KW_RLIKE | KW_REGEXP | KW_TEMPORARY | KW_EXPLAIN | KW_FORMATTED | KW_PRETTY | KW_DEPENDENCY | KW_LOGICAL | KW_SERDE | KW_WITH | KW_DEFERRED | KW_SERDEPROPERTIES | KW_DBPROPERTIES | KW_LIMIT | KW_SET | KW_UNSET | KW_TBLPROPERTIES | KW_IDXPROPERTIES | KW_VALUE_TYPE | KW_ELEM_TYPE | KW_MAPJOIN | KW_STREAMTABLE | KW_HOLD_DDLTIME | KW_CLUSTERSTATUS | KW_UTC | KW_UTCTIMESTAMP | KW_LONG | KW_DELETE | KW_PLUS | KW_MINUS | KW_FETCH | KW_INTERSECT | KW_VIEW | KW_IN | KW_DATABASES | KW_MATERIALIZED | KW_SCHEMA | KW_SCHEMAS | KW_GRANT | KW_REVOKE | KW_SSL | KW_UNDO | KW_LOCK | KW_LOCKS | KW_UNLOCK | KW_SHARED | KW_EXCLUSIVE | KW_PROCEDURE | KW_UNSIGNED | KW_WHILE | KW_READ | KW_READS | KW_PURGE | KW_RANGE | KW_AN
ALYZE | KW_BEFORE | KW_BETWEEN | KW_BOTH | KW_BINARY | KW_CONTINUE | KW_CURSOR | KW_TRIGGER | KW_RECORDREADER | KW_RECORDWRITER | KW_SEMI | KW_LATERAL | KW_TOUCH | KW_ARCHIVE | KW_UNARCHIVE | KW_COMPUTE | KW_STATISTICS | KW_USE | KW_OPTION | KW_CONCATENATE | KW_SHOW_DATABASE | KW_UPDATE | KW_RESTRICT | KW_CASCADE | KW_SKEWED | KW_ROLLUP | KW_CUBE | KW_DIRECTORIES | KW_FOR | KW_GROUPING | KW_SETS | KW_TRUNCATE | KW_NOSCAN | KW_USER | KW_ROLE | KW_ROLES | KW_INNER | KW_DEFINED | KW_ADMIN | KW_JAR | KW_FILE | KW_OWNER | KW_PRINCIPALS | KW_ALL | KW_DEFAULT | KW_NONE | KW_COMPACT | KW_COMPACTIONS | KW_TRANSACTIONS | KW_REWRITE | KW_AUTHORIZATION | KW_VALUES | KW_URI | KW_SERVER
+ KW_TRUE | KW_FALSE | KW_LIKE | KW_EXISTS | KW_ASC | KW_DESC | KW_ORDER | KW_GROUP | KW_BY | KW_AS | KW_INSERT | KW_OVERWRITE | KW_OUTER | KW_LEFT | KW_RIGHT | KW_FULL | KW_PARTITION | KW_PARTITIONS | KW_TABLE | KW_TABLES | KW_COLUMNS | KW_INDEX | KW_INDEXES | KW_REBUILD | KW_FUNCTIONS | KW_SHOW | KW_MSCK | KW_REPAIR | KW_DIRECTORY | KW_LOCAL | KW_USING | KW_CLUSTER | KW_DISTRIBUTE | KW_SORT | KW_LOAD | KW_EXPORT | KW_IMPORT | KW_DATA | KW_INPATH | KW_IS | KW_NULL | KW_CREATE | KW_EXTERNAL | KW_ALTER | KW_CHANGE | KW_FIRST | KW_AFTER | KW_DESCRIBE | KW_DROP | KW_RENAME | KW_IGNORE | KW_PROTECTION | KW_TO | KW_COMMENT | KW_BOOLEAN | KW_TINYINT | KW_SMALLINT | KW_INT | KW_BIGINT | KW_FLOAT | KW_DOUBLE | KW_DATE | KW_DATETIME | KW_TIMESTAMP | KW_DECIMAL | KW_STRING | KW_ARRAY | KW_STRUCT | KW_UNIONTYPE | KW_PARTITIONED | KW_CLUSTERED | KW_SORTED | KW_INTO | KW_BUCKETS | KW_ROW | KW_ROWS | KW_FORMAT | KW_DELIMITED | KW_FIELDS | KW_TERMINATED | KW_ESCAPED | KW_COLLECTION | KW_ITEMS |
KW_KEYS | KW_KEY_TYPE | KW_LINES | KW_STORED | KW_FILEFORMAT | KW_INPUTFORMAT | KW_OUTPUTFORMAT | KW_INPUTDRIVER | KW_OUTPUTDRIVER | KW_OFFLINE | KW_ENABLE | KW_DISABLE | KW_READONLY | KW_NO_DROP | KW_LOCATION | KW_BUCKET | KW_OUT | KW_OF | KW_PERCENT | KW_ADD | KW_REPLACE | KW_RLIKE | KW_REGEXP | KW_TEMPORARY | KW_EXPLAIN | KW_FORMATTED | KW_PRETTY | KW_DEPENDENCY | KW_LOGICAL | KW_SERDE | KW_WITH | KW_DEFERRED | KW_SERDEPROPERTIES | KW_DBPROPERTIES | KW_LIMIT | KW_SET | KW_UNSET | KW_TBLPROPERTIES | KW_IDXPROPERTIES | KW_VALUE_TYPE | KW_ELEM_TYPE | KW_MAPJOIN | KW_STREAMTABLE | KW_HOLD_DDLTIME | KW_CLUSTERSTATUS | KW_UTC | KW_UTCTIMESTAMP | KW_LONG | KW_DELETE | KW_PLUS | KW_MINUS | KW_FETCH | KW_INTERSECT | KW_VIEW | KW_IN | KW_DATABASES | KW_MATERIALIZED | KW_SCHEMA | KW_SCHEMAS | KW_GRANT | KW_REVOKE | KW_SSL | KW_UNDO | KW_LOCK | KW_LOCKS | KW_UNLOCK | KW_SHARED | KW_EXCLUSIVE | KW_PROCEDURE | KW_UNSIGNED | KW_WHILE | KW_READ | KW_READS | KW_PURGE | KW_RANGE | KW_ANALYZE | KW_
BEFORE | KW_BETWEEN | KW_BOTH | KW_BINARY | KW_CONTINUE | KW_CURSOR | KW_TRIGGER | KW_RECORDREADER | KW_RECORDWRITER | KW_SEMI | KW_LATERAL | KW_TOUCH | KW_ARCHIVE | KW_UNARCHIVE | KW_COMPUTE | KW_STATISTICS | KW_USE | KW_OPTION | KW_CONCATENATE | KW_SHOW_DATABASE | KW_UPDATE | KW_RESTRICT | KW_CASCADE | KW_SKEWED | KW_ROLLUP | KW_CUBE | KW_DIRECTORIES | KW_FOR | KW_GROUPING | KW_SETS | KW_TRUNCATE | KW_NOSCAN | KW_USER | KW_ROLE | KW_ROLES | KW_INNER | KW_DEFINED | KW_ADMIN | KW_JAR | KW_FILE | KW_OWNER | KW_PRINCIPALS | KW_ALL | KW_DEFAULT | KW_NONE | KW_COMPACT | KW_COMPACTIONS | KW_TRANSACTIONS | KW_REWRITE | KW_AUTHORIZATION | KW_VALUES | KW_URI | KW_SERVER
;
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java?rev=1658489&r1=1658488&r2=1658489&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java Mon Feb 9 18:07:01 2015
@@ -420,7 +420,7 @@ public class SemanticAnalyzer extends Ba
qbexpr.setQB(qb);
}
break;
- case HiveParser.TOK_UNION: {
+ case HiveParser.TOK_UNIONALL: {
qbexpr.setOpcode(QBExpr.Opcode.UNION);
// query 1
assert (ast.getChild(0) != null);
@@ -430,7 +430,7 @@ public class SemanticAnalyzer extends Ba
qbexpr.setQBExpr1(qbexpr1);
// query 2
- assert (ast.getChild(0) != null);
+ assert (ast.getChild(1) != null);
QBExpr qbexpr2 = new QBExpr(alias + "-subquery2");
doPhase1QBExpr((ASTNode) ast.getChild(1), qbexpr2, id + "-subquery2",
alias + "-subquery2");
@@ -1324,7 +1324,7 @@ public class SemanticAnalyzer extends Ba
break;
- case HiveParser.TOK_UNION:
+ case HiveParser.TOK_UNIONALL:
if (!qbp.getIsSubQ()) {
// this shouldn't happen. The parser should have converted the union to be
// contained in a subquery. Just in case, we keep the error as a fallback.
Added: hive/trunk/ql/src/test/queries/clientnegative/unionClusterBy.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/unionClusterBy.q?rev=1658489&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/unionClusterBy.q (added)
+++ hive/trunk/ql/src/test/queries/clientnegative/unionClusterBy.q Mon Feb 9 18:07:01 2015
@@ -0,0 +1,9 @@
+-- orderByClause clusterByClause distributeByClause sortByClause limitClause
+-- can only be applied to the whole union.
+
+select key from src cluster by key
+union all
+select key from src;
+
+
+
Added: hive/trunk/ql/src/test/queries/clientnegative/unionDistributeBy.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/unionDistributeBy.q?rev=1658489&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/unionDistributeBy.q (added)
+++ hive/trunk/ql/src/test/queries/clientnegative/unionDistributeBy.q Mon Feb 9 18:07:01 2015
@@ -0,0 +1,10 @@
+-- orderByClause clusterByClause distributeByClause sortByClause limitClause
+-- can only be applied to the whole union.
+
+select key from src distribute by key
+union all
+select key from src;
+
+
+
+
Added: hive/trunk/ql/src/test/queries/clientnegative/unionLimit.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/unionLimit.q?rev=1658489&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/unionLimit.q (added)
+++ hive/trunk/ql/src/test/queries/clientnegative/unionLimit.q Mon Feb 9 18:07:01 2015
@@ -0,0 +1,10 @@
+-- orderByClause clusterByClause distributeByClause sortByClause limitClause
+-- can only be applied to the whole union.
+
+select key from src limit 1
+union all
+select key from src;
+
+
+
+
Added: hive/trunk/ql/src/test/queries/clientnegative/unionOrderBy.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/unionOrderBy.q?rev=1658489&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/unionOrderBy.q (added)
+++ hive/trunk/ql/src/test/queries/clientnegative/unionOrderBy.q Mon Feb 9 18:07:01 2015
@@ -0,0 +1,9 @@
+-- orderByClause clusterByClause distributeByClause sortByClause limitClause
+-- can only be applied to the whole union.
+
+select key from src order by key
+union all
+select key from src;
+
+
+
Added: hive/trunk/ql/src/test/queries/clientnegative/unionSortBy.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/unionSortBy.q?rev=1658489&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/unionSortBy.q (added)
+++ hive/trunk/ql/src/test/queries/clientnegative/unionSortBy.q Mon Feb 9 18:07:01 2015
@@ -0,0 +1,8 @@
+-- orderByClause clusterByClause distributeByClause sortByClause limitClause
+-- can only be applied to the whole union.
+
+select key from src sort by key
+union all
+select key from src;
+
+
Modified: hive/trunk/ql/src/test/queries/clientpositive/cbo_union.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/cbo_union.q?rev=1658489&r1=1658488&r2=1658489&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/cbo_union.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/cbo_union.q Mon Feb 9 18:07:01 2015
@@ -7,7 +7,7 @@ set hive.auto.convert.join=false;
-- SORT_QUERY_RESULTS
-- 11. Union All
-select * from cbo_t1 order by key, c_boolean, value, dt union all select * from cbo_t2 order by key, c_boolean, value, dt;
+select * from (select * from cbo_t1 order by key, c_boolean, value, dt)a union all select * from (select * from cbo_t2 order by key, c_boolean, value, dt)b;
select key from (select key, c_int from (select * from cbo_t1 union all select * from cbo_t2 where cbo_t2.key >=0)r1 union all select key, c_int from cbo_t3)r2 where key >=0 order by key;
select r2.key from (select key, c_int from (select key, c_int from cbo_t1 union all select key, c_int from cbo_t3 )r1 union all select key, c_int from cbo_t3)r2 join (select key, c_int from (select * from cbo_t1 union all select * from cbo_t2 where cbo_t2.key >=0)r1 union all select key, c_int from cbo_t3)r3 on r2.key=r3.key where r3.key >=0 order by r2.key;
Modified: hive/trunk/ql/src/test/queries/clientpositive/explode_null.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/explode_null.q?rev=1658489&r1=1658488&r2=1658489&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/explode_null.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/explode_null.q Mon Feb 9 18:07:01 2015
@@ -1,10 +1,10 @@
SELECT explode(col) AS myCol FROM
- (SELECT array(1,2,3) AS col FROM src LIMIT 1
+ (select * from (SELECT array(1,2,3) AS col FROM src LIMIT 1)ea
UNION ALL
- SELECT IF(false, array(1,2,3), NULL) AS col FROM src LIMIT 1) a;
+ select * from (SELECT IF(false, array(1,2,3), NULL) AS col FROM src LIMIT 1)eb) a;
SELECT explode(col) AS (myCol1,myCol2) FROM
- (SELECT map(1,'one',2,'two',3,'three') AS col FROM src LIMIT 1
+ (select * from (SELECT map(1,'one',2,'two',3,'three') AS col FROM src LIMIT 1)ea
UNION ALL
- SELECT IF(false, map(1,'one',2,'two',3,'three'), NULL) AS col FROM src LIMIT 1) a;
+ select * from (SELECT IF(false, map(1,'one',2,'two',3,'three'), NULL) AS col FROM src LIMIT 1)eb ) a;
\ No newline at end of file
Modified: hive/trunk/ql/src/test/queries/clientpositive/input25.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/input25.q?rev=1658489&r1=1658488&r2=1658489&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/input25.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/input25.q Mon Feb 9 18:07:01 2015
@@ -5,15 +5,15 @@ alter table tst add partition (d='2009-0
explain
select * from (
- select * from tst x where x.d='2009-01-01' limit 10
+ select * from (select * from tst x where x.d='2009-01-01' limit 10)a
union all
- select * from tst x where x.d='2009-02-02' limit 10
+ select * from (select * from tst x where x.d='2009-02-02' limit 10)b
) subq;
select * from (
- select * from tst x where x.d='2009-01-01' limit 10
+ select * from (select * from tst x where x.d='2009-01-01' limit 10)a
union all
- select * from tst x where x.d='2009-02-02' limit 10
+ select * from (select * from tst x where x.d='2009-02-02' limit 10)b
) subq;
Modified: hive/trunk/ql/src/test/queries/clientpositive/input26.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/input26.q?rev=1658489&r1=1658488&r2=1658489&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/input26.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/input26.q Mon Feb 9 18:07:01 2015
@@ -1,12 +1,12 @@
explain
select * from (
- select * from srcpart a where a.ds = '2008-04-08' and a.hr = '11' order by a.key limit 5
+ select * from (select * from srcpart a where a.ds = '2008-04-08' and a.hr = '11' order by a.key limit 5)pa
union all
- select * from srcpart b where b.ds = '2008-04-08' and b.hr = '14' limit 5
+ select * from (select * from srcpart b where b.ds = '2008-04-08' and b.hr = '14' limit 5)pb
)subq;
select * from (
- select * from srcpart a where a.ds = '2008-04-08' and a.hr = '11' order by a.key limit 5
+ select * from (select * from srcpart a where a.ds = '2008-04-08' and a.hr = '11' order by a.key limit 5)pa
union all
- select * from srcpart b where b.ds = '2008-04-08' and b.hr = '14' limit 5
+ select * from (select * from srcpart b where b.ds = '2008-04-08' and b.hr = '14' limit 5)pb
)subq;
Modified: hive/trunk/ql/src/test/queries/clientpositive/load_dyn_part14.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/load_dyn_part14.q?rev=1658489&r1=1658488&r2=1658489&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/load_dyn_part14.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/load_dyn_part14.q Mon Feb 9 18:07:01 2015
@@ -14,20 +14,20 @@ set hive.exec.dynamic.partition.mode=non
explain
insert overwrite table nzhang_part14 partition(value)
select key, value from (
- select 'k1' as key, cast(null as string) as value from src limit 2
+ select * from (select 'k1' as key, cast(null as string) as value from src limit 2)a
union all
- select 'k2' as key, '' as value from src limit 2
+ select * from (select 'k2' as key, '' as value from src limit 2)b
union all
- select 'k3' as key, ' ' as value from src limit 2
+ select * from (select 'k3' as key, ' ' as value from src limit 2)c
) T;
insert overwrite table nzhang_part14 partition(value)
select key, value from (
- select 'k1' as key, cast(null as string) as value from src limit 2
+ select * from (select 'k1' as key, cast(null as string) as value from src limit 2)a
union all
- select 'k2' as key, '' as value from src limit 2
+ select * from (select 'k2' as key, '' as value from src limit 2)b
union all
- select 'k3' as key, ' ' as value from src limit 2
+ select * from (select 'k3' as key, ' ' as value from src limit 2)c
) T;
Modified: hive/trunk/ql/src/test/queries/clientpositive/metadataOnlyOptimizer.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/metadataOnlyOptimizer.q?rev=1658489&r1=1658488&r2=1658489&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/metadataOnlyOptimizer.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/metadataOnlyOptimizer.q Mon Feb 9 18:07:01 2015
@@ -33,9 +33,9 @@ UNION all
SELECT key as key from src
) tab group by key;
-select k from (SELECT '1' as k from src limit 0 union all select key as k from src limit 1)tab;
+select k from (select * from (SELECT '1' as k from src limit 0)a union all select key as k from src limit 1)tab;
-select k from (SELECT '1' as k from src limit 1 union all select key as k from src limit 0)tab;
+select k from (select * from (SELECT '1' as k from src limit 1)a union all select key as k from src limit 0)tab;
select max(ds) from srcpart;
Modified: hive/trunk/ql/src/test/queries/clientpositive/script_env_var1.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/script_env_var1.q?rev=1658489&r1=1658488&r2=1658489&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/script_env_var1.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/script_env_var1.q Mon Feb 9 18:07:01 2015
@@ -1,5 +1,5 @@
-- Verifies that script operator ID environment variables have unique values
-- in each instance of the script operator.
SELECT count(1) FROM
-( SELECT TRANSFORM('echo $HIVE_SCRIPT_OPERATOR_ID') USING 'sh' AS key FROM src LIMIT 1 UNION ALL
- SELECT TRANSFORM('echo $HIVE_SCRIPT_OPERATOR_ID') USING 'sh' AS key FROM src LIMIT 1 ) a GROUP BY key;
+( SELECT * FROM (SELECT TRANSFORM('echo $HIVE_SCRIPT_OPERATOR_ID') USING 'sh' AS key FROM src LIMIT 1)x UNION ALL
+ SELECT * FROM (SELECT TRANSFORM('echo $HIVE_SCRIPT_OPERATOR_ID') USING 'sh' AS key FROM src LIMIT 1)y ) a GROUP BY key;
Modified: hive/trunk/ql/src/test/queries/clientpositive/script_env_var2.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/script_env_var2.q?rev=1658489&r1=1658488&r2=1658489&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/script_env_var2.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/script_env_var2.q Mon Feb 9 18:07:01 2015
@@ -1,5 +1,5 @@
set hive.script.operator.id.env.var = MY_ID;
-- Same test as script_env_var1, but test setting the variable name
SELECT count(1) FROM
-( SELECT TRANSFORM('echo $MY_ID') USING 'sh' AS key FROM src LIMIT 1 UNION ALL
- SELECT TRANSFORM('echo $MY_ID') USING 'sh' AS key FROM src LIMIT 1 ) a GROUP BY key;
+( SELECT * FROM (SELECT TRANSFORM('echo $MY_ID') USING 'sh' AS key FROM src LIMIT 1)a UNION ALL
+ SELECT * FROM (SELECT TRANSFORM('echo $MY_ID') USING 'sh' AS key FROM src LIMIT 1)b ) a GROUP BY key;
Modified: hive/trunk/ql/src/test/queries/clientpositive/union3.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/union3.q?rev=1658489&r1=1658488&r2=1658489&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/union3.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/union3.q Mon Feb 9 18:07:01 2015
@@ -5,17 +5,16 @@ SELECT *
FROM (
SELECT 1 AS id
FROM (SELECT * FROM src LIMIT 1) s1
- CLUSTER BY id
UNION ALL
SELECT 2 AS id
FROM (SELECT * FROM src LIMIT 1) s1
- CLUSTER BY id
UNION ALL
SELECT 3 AS id
FROM (SELECT * FROM src LIMIT 1) s2
UNION ALL
SELECT 4 AS id
FROM (SELECT * FROM src LIMIT 1) s2
+ CLUSTER BY id
) a;
@@ -27,17 +26,16 @@ SELECT *
FROM (
SELECT 1 AS id
FROM (SELECT * FROM src LIMIT 1) s1
- CLUSTER BY id
UNION ALL
SELECT 2 AS id
FROM (SELECT * FROM src LIMIT 1) s1
- CLUSTER BY id
UNION ALL
SELECT 3 AS id
FROM (SELECT * FROM src LIMIT 1) s2
UNION ALL
SELECT 4 AS id
FROM (SELECT * FROM src LIMIT 1) s2
+ CLUSTER BY id
) a;
-select * from union_out cluster by id;
+select * from union_out;
Added: hive/trunk/ql/src/test/queries/clientpositive/unionDistinct_1.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/unionDistinct_1.q?rev=1658489&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/unionDistinct_1.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/unionDistinct_1.q Mon Feb 9 18:07:01 2015
@@ -0,0 +1,1134 @@
+-- union10.q
+
+
+
+-- union case: all subqueries are a map-reduce jobs, 3 way union, same input for all sub-queries, followed by filesink
+
+create table tmptable(key string, value int);
+
+explain
+insert overwrite table tmptable
+ select unionsrc.key, unionsrc.value FROM (select 'tst1' as key, count(1) as value from src s1
+ UNION DISTINCT
+ select 'tst2' as key, count(1) as value from src s2
+ UNION DISTINCT
+ select 'tst3' as key, count(1) as value from src s3) unionsrc;
+
+
+insert overwrite table tmptable
+ select unionsrc.key, unionsrc.value FROM (select 'tst1' as key, count(1) as value from src s1
+ UNION DISTINCT
+ select 'tst2' as key, count(1) as value from src s2
+ UNION DISTINCT
+ select 'tst3' as key, count(1) as value from src s3) unionsrc;
+
+
+select * from tmptable x sort by x.key;
+
+-- union11.q
+
+
+-- SORT_BEFORE_DIFF
+-- union case: all subqueries are a map-reduce jobs, 3 way union, same input for all sub-queries, followed by reducesink
+
+explain
+ select unionsrc.key, count(1) FROM (select 'tst1' as key, count(1) as value from src s1
+ UNION DISTINCT
+ select 'tst2' as key, count(1) as value from src s2
+ UNION DISTINCT
+ select 'tst3' as key, count(1) as value from src s3) unionsrc group by unionsrc.key;
+
+
+ select unionsrc.key, count(1) FROM (select 'tst1' as key, count(1) as value from src s1
+ UNION DISTINCT
+ select 'tst2' as key, count(1) as value from src s2
+ UNION DISTINCT
+ select 'tst3' as key, count(1) as value from src s3) unionsrc group by unionsrc.key;
+
+
+
+-- union12.q
+
+
+
+-- union case: all subqueries are a map-reduce jobs, 3 way union, different inputs for all sub-queries, followed by filesink
+
+create table tmptable12(key string, value int);
+
+explain
+insert overwrite table tmptable12
+ select unionsrc.key, unionsrc.value FROM (select 'tst1' as key, count(1) as value from src s1
+ UNION DISTINCT
+ select 'tst2' as key, count(1) as value from src1 s2
+ UNION DISTINCT
+ select 'tst3' as key, count(1) as value from srcbucket s3) unionsrc;
+
+
+insert overwrite table tmptable12
+ select unionsrc.key, unionsrc.value FROM (select 'tst1' as key, count(1) as value from src s1
+ UNION DISTINCT
+ select 'tst2' as key, count(1) as value from src1 s2
+ UNION DISTINCT
+ select 'tst3' as key, count(1) as value from srcbucket s3) unionsrc;
+
+select * from tmptable12 x sort by x.key;
+-- union13.q
+
+-- SORT_BEFORE_DIFF
+-- union case: both subqueries are a map-only jobs, same input, followed by filesink
+
+explain
+ select unionsrc.key, unionsrc.value FROM (select s1.key as key, s1.value as value from src s1 UNION DISTINCT
+ select s2.key as key, s2.value as value from src s2) unionsrc;
+
+select unionsrc.key, unionsrc.value FROM (select s1.key as key, s1.value as value from src s1 UNION DISTINCT
+ select s2.key as key, s2.value as value from src s2) unionsrc;
+-- union14.q
+
+
+-- SORT_BEFORE_DIFF
+-- union case: 1 subquery is a map-reduce job, different inputs for sub-queries, followed by reducesink
+
+explain
+ select unionsrc.key, count(1) FROM (select s2.key as key, s2.value as value from src1 s2
+ UNION DISTINCT
+ select 'tst1' as key, cast(count(1) as string) as value from src s1)
+ unionsrc group by unionsrc.key;
+
+
+
+ select unionsrc.key, count(1) FROM (select s2.key as key, s2.value as value from src1 s2
+ UNION DISTINCT
+ select 'tst1' as key, cast(count(1) as string) as value from src s1)
+ unionsrc group by unionsrc.key;
+-- union15.q
+
+
+-- SORT_BEFORE_DIFF
+-- union case: 1 subquery is a map-reduce job, different inputs for sub-queries, followed by reducesink
+
+explain
+ select unionsrc.key, count(1) FROM (select 'tst1' as key, cast(count(1) as string) as value from src s1
+ UNION DISTINCT
+ select s2.key as key, s2.value as value from src1 s2
+ UNION DISTINCT
+ select s3.key as key, s3.value as value from src1 s3) unionsrc group by unionsrc.key;
+
+ select unionsrc.key, count(1) FROM (select 'tst1' as key, cast(count(1) as string) as value from src s1
+ UNION DISTINCT
+ select s2.key as key, s2.value as value from src1 s2
+ UNION DISTINCT
+ select s3.key as key, s3.value as value from src1 s3) unionsrc group by unionsrc.key;
+
+
+-- union16.q
+
+-- SORT_BEFORE_DIFF
+EXPLAIN
+SELECT count(1) FROM (
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src) src;
+
+
+SELECT count(1) FROM (
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src UNION DISTINCT
+ SELECT key, value FROM src) src;
+-- union17.q
+
+CREATE TABLE DEST1(key STRING, value STRING) STORED AS TEXTFILE;
+CREATE TABLE DEST2(key STRING, val1 STRING, val2 STRING) STORED AS TEXTFILE;
+
+-- SORT_BEFORE_DIFF
+-- union case:map-reduce sub-queries followed by multi-table insert
+
+explain
+FROM (select 'tst1' as key, cast(count(1) as string) as value from src s1
+ UNION DISTINCT
+ select s2.key as key, s2.value as value from src s2) unionsrc
+INSERT OVERWRITE TABLE DEST1 SELECT unionsrc.key, COUNT(DISTINCT SUBSTR(unionsrc.value,5)) GROUP BY unionsrc.key
+INSERT OVERWRITE TABLE DEST2 SELECT unionsrc.key, unionsrc.value, COUNT(DISTINCT SUBSTR(unionsrc.value,5)) GROUP BY unionsrc.key, unionsrc.value;
+
+FROM (select 'tst1' as key, cast(count(1) as string) as value from src s1
+ UNION DISTINCT
+ select s2.key as key, s2.value as value from src s2) unionsrc
+INSERT OVERWRITE TABLE DEST1 SELECT unionsrc.key, COUNT(DISTINCT SUBSTR(unionsrc.value,5)) GROUP BY unionsrc.key
+INSERT OVERWRITE TABLE DEST2 SELECT unionsrc.key, unionsrc.value, COUNT(DISTINCT SUBSTR(unionsrc.value,5)) GROUP BY unionsrc.key, unionsrc.value;
+
+SELECT DEST1.* FROM DEST1;
+SELECT DEST2.* FROM DEST2;
+-- union18.q
+
+CREATE TABLE DEST118(key STRING, value STRING) STORED AS TEXTFILE;
+CREATE TABLE DEST218(key STRING, val1 STRING, val2 STRING) STORED AS TEXTFILE;
+
+-- union case:map-reduce sub-queries followed by multi-table insert
+
+explain
+FROM (select 'tst1' as key, cast(count(1) as string) as value from src s1
+ UNION DISTINCT
+ select s2.key as key, s2.value as value from src s2) unionsrc
+INSERT OVERWRITE TABLE DEST118 SELECT unionsrc.key, unionsrc.value
+INSERT OVERWRITE TABLE DEST218 SELECT unionsrc.key, unionsrc.value, unionsrc.value;
+
+FROM (select 'tst1' as key, cast(count(1) as string) as value from src s1
+ UNION DISTINCT
+ select s2.key as key, s2.value as value from src s2) unionsrc
+INSERT OVERWRITE TABLE DEST118 SELECT unionsrc.key, unionsrc.value
+INSERT OVERWRITE TABLE DEST218 SELECT unionsrc.key, unionsrc.value, unionsrc.value;
+
+SELECT DEST118.* FROM DEST118 SORT BY DEST118.key, DEST118.value;
+SELECT DEST218.* FROM DEST218 SORT BY DEST218.key, DEST218.val1, DEST218.val2;
+-- union19.q
+
+
+
+
+CREATE TABLE DEST119(key STRING, value STRING) STORED AS TEXTFILE;
+CREATE TABLE DEST219(key STRING, val1 STRING, val2 STRING) STORED AS TEXTFILE;
+
+-- union case:map-reduce sub-queries followed by multi-table insert
+
+explain
+FROM (select 'tst1' as key, cast(count(1) as string) as value from src s1
+ UNION DISTINCT
+ select s2.key as key, s2.value as value from src s2) unionsrc
+INSERT OVERWRITE TABLE DEST119 SELECT unionsrc.key, count(unionsrc.value) group by unionsrc.key
+INSERT OVERWRITE TABLE DEST219 SELECT unionsrc.key, unionsrc.value, unionsrc.value;
+
+FROM (select 'tst1' as key, cast(count(1) as string) as value from src s1
+ UNION DISTINCT
+ select s2.key as key, s2.value as value from src s2) unionsrc
+INSERT OVERWRITE TABLE DEST119 SELECT unionsrc.key, count(unionsrc.value) group by unionsrc.key
+INSERT OVERWRITE TABLE DEST219 SELECT unionsrc.key, unionsrc.value, unionsrc.value;
+
+SELECT DEST119.* FROM DEST119 SORT BY DEST119.key, DEST119.value;
+SELECT DEST219.* FROM DEST219 SORT BY DEST219.key, DEST219.val1, DEST219.val2;
+
+
+
+-- union2.q
+
+-- SORT_BEFORE_DIFF
+-- union case: both subqueries are map-reduce jobs on same input, followed by reduce sink
+
+explain
+ select count(1) FROM (select s1.key as key, s1.value as value from src s1 UNION DISTINCT
+ select s2.key as key, s2.value as value from src s2) unionsrc;
+
+select count(1) FROM (select s1.key as key, s1.value as value from src s1 UNION DISTINCT
+ select s2.key as key, s2.value as value from src s2) unionsrc;
+-- union20.q
+
+-- SORT_BEFORE_DIFF
+-- union :map-reduce sub-queries followed by join
+
+explain
+SELECT unionsrc1.key, unionsrc1.value, unionsrc2.key, unionsrc2.value
+FROM (select 'tst1' as key, cast(count(1) as string) as value from src s1
+ UNION DISTINCT
+ select s2.key as key, s2.value as value from src s2 where s2.key < 10) unionsrc1
+JOIN
+ (select 'tst1' as key, cast(count(1) as string) as value from src s3
+ UNION DISTINCT
+ select s4.key as key, s4.value as value from src s4 where s4.key < 10) unionsrc2
+ON (unionsrc1.key = unionsrc2.key);
+
+SELECT unionsrc1.key, unionsrc1.value, unionsrc2.key, unionsrc2.value
+FROM (select 'tst1' as key, cast(count(1) as string) as value from src s1
+ UNION DISTINCT
+ select s2.key as key, s2.value as value from src s2 where s2.key < 10) unionsrc1
+JOIN
+ (select 'tst1' as key, cast(count(1) as string) as value from src s3
+ UNION DISTINCT
+ select s4.key as key, s4.value as value from src s4 where s4.key < 10) unionsrc2
+ON (unionsrc1.key = unionsrc2.key);
+-- union21.q
+
+-- SORT_BEFORE_DIFF
+-- union of constants, udf outputs, and columns from text table and thrift table
+
+explain
+SELECT key, count(1)
+FROM (
+ SELECT '1' as key from src
+ UNION DISTINCT
+ SELECT reverse(key) as key from src
+ UNION DISTINCT
+ SELECT key as key from src
+ UNION DISTINCT
+ SELECT astring as key from src_thrift
+ UNION DISTINCT
+ SELECT lstring[0] as key from src_thrift
+) union_output
+GROUP BY key;
+
+SELECT key, count(1)
+FROM (
+ SELECT '1' as key from src
+ UNION DISTINCT
+ SELECT reverse(key) as key from src
+ UNION DISTINCT
+ SELECT key as key from src
+ UNION DISTINCT
+ SELECT astring as key from src_thrift
+ UNION DISTINCT
+ SELECT lstring[0] as key from src_thrift
+) union_output
+GROUP BY key;
+-- union22.q
+
+-- SORT_QUERY_RESULTS
+
+create table dst_union22(k1 string, k2 string, k3 string, k4 string) partitioned by (ds string);
+create table dst_union22_delta(k0 string, k1 string, k2 string, k3 string, k4 string, k5 string) partitioned by (ds string);
+
+insert overwrite table dst_union22 partition (ds='1')
+select key, value, key , value from src;
+
+insert overwrite table dst_union22_delta partition (ds='1')
+select key, key, value, key, value, value from src;
+
+set hive.merge.mapfiles=false;
+
+set hive.auto.convert.join=true;
+set hive.auto.convert.join.noconditionaltask=true;
+set hive.auto.convert.join.noconditionaltask.size=10000;
+
+-- Since the inputs are small, it should be automatically converted to mapjoin
+
+explain extended
+insert overwrite table dst_union22 partition (ds='2')
+select * from
+(
+select k1 as k1, k2 as k2, k3 as k3, k4 as k4 from dst_union22_delta where ds = '1' and k0 <= 50
+UNION DISTINCT
+select a.k1 as k1, a.k2 as k2, b.k3 as k3, b.k4 as k4
+from dst_union22 a left outer join (select * from dst_union22_delta where ds = '1' and k0 > 50) b on
+a.k1 = b.k1 and a.ds='1'
+where a.k1 > 20
+)
+subq;
+
+insert overwrite table dst_union22 partition (ds='2')
+select * from
+(
+select k1 as k1, k2 as k2, k3 as k3, k4 as k4 from dst_union22_delta where ds = '1' and k0 <= 50
+UNION DISTINCT
+select a.k1 as k1, a.k2 as k2, b.k3 as k3, b.k4 as k4
+from dst_union22 a left outer join (select * from dst_union22_delta where ds = '1' and k0 > 50) b on
+a.k1 = b.k1 and a.ds='1'
+where a.k1 > 20
+)
+subq;
+
+select * from dst_union22 where ds = '2';
+-- union23.q
+
+explain
+select s.key2, s.value2
+from (
+ select transform(key, value) using 'cat' as (key2, value2)
+ from src
+ UNION DISTINCT
+ select key as key2, value as value2 from src) s
+order by s.key2, s.value2;
+
+select s.key2, s.value2
+from (
+ select transform(key, value) using 'cat' as (key2, value2)
+ from src
+ UNION DISTINCT
+ select key as key2, value as value2 from src) s
+order by s.key2, s.value2;
+
+-- union24.q
+
+-- SORT_QUERY_RESULTS
+
+create table src2 as select key, count(1) as count from src group by key;
+create table src3 as select * from src2;
+create table src4 as select * from src2;
+create table src5 as select * from src2;
+
+
+set hive.merge.mapfiles=false;
+set hive.merge.mapredfiles=false;
+
+
+explain extended
+select s.key, s.count from (
+ select key, count from src2 where key < 10
+ UNION DISTINCT
+ select key, count from src3 where key < 10
+ UNION DISTINCT
+ select key, count from src4 where key < 10
+ UNION DISTINCT
+ select key, count(1) as count from src5 where key < 10 group by key
+)s
+;
+
+select s.key, s.count from (
+ select key, count from src2 where key < 10
+ UNION DISTINCT
+ select key, count from src3 where key < 10
+ UNION DISTINCT
+ select key, count from src4 where key < 10
+ UNION DISTINCT
+ select key, count(1) as count from src5 where key < 10 group by key
+)s
+;
+
+explain extended
+select s.key, s.count from (
+ select key, count from src2 where key < 10
+ UNION DISTINCT
+ select key, count from src3 where key < 10
+ UNION DISTINCT
+ select a.key as key, b.count as count from src4 a join src5 b on a.key=b.key where a.key < 10
+)s
+;
+
+select s.key, s.count from (
+ select key, count from src2 where key < 10
+ UNION DISTINCT
+ select key, count from src3 where key < 10
+ UNION DISTINCT
+ select a.key as key, b.count as count from src4 a join src5 b on a.key=b.key where a.key < 10
+)s
+;
+
+explain extended
+select s.key, s.count from (
+ select key, count from src2 where key < 10
+ UNION DISTINCT
+ select key, count from src3 where key < 10
+ UNION DISTINCT
+ select a.key as key, count(1) as count from src4 a join src5 b on a.key=b.key where a.key < 10 group by a.key
+)s
+;
+
+select s.key, s.count from (
+ select key, count from src2 where key < 10
+ UNION DISTINCT
+ select key, count from src3 where key < 10
+ UNION DISTINCT
+ select a.key as key, count(1) as count from src4 a join src5 b on a.key=b.key where a.key < 10 group by a.key
+)s
+;
+-- union25.q
+
+create table tmp_srcpart like srcpart;
+
+insert overwrite table tmp_srcpart partition (ds='2008-04-08', hr='11')
+select key, value from srcpart where ds='2008-04-08' and hr='11';
+
+explain
+create table tmp_unionall as
+SELECT count(1) as counts, key, value
+FROM
+(
+ SELECT key, value FROM srcpart a WHERE a.ds='2008-04-08' and a.hr='11'
+
+ UNION DISTINCT
+
+ SELECT key, key as value FROM (
+ SELECT distinct key FROM (
+ SELECT key, value FROM tmp_srcpart a WHERE a.ds='2008-04-08' and a.hr='11'
+ UNION DISTINCT
+ SELECT key, value FROM tmp_srcpart b WHERE b.ds='2008-04-08' and b.hr='11'
+ )t
+ ) master_table
+) a GROUP BY key, value
+;
+-- union26.q
+
+-- SORT_QUERY_RESULTS
+
+EXPLAIN
+SELECT
+count(1) as counts,
+key,
+value
+FROM
+(
+
+SELECT
+a.key, a.value
+FROM srcpart a JOIN srcpart b
+ON a.ds='2008-04-08' and a.hr='11' and b.ds='2008-04-08' and b.hr='12'
+AND a.key = b.key
+
+UNION DISTINCT
+
+select key, value
+FROM srcpart LATERAL VIEW explode(array(1,2,3)) myTable AS myCol
+WHERE ds='2008-04-08' and hr='11'
+) a
+group by key, value
+;
+
+SELECT
+count(1) as counts,
+key,
+value
+FROM
+(
+
+SELECT
+a.key, a.value
+FROM srcpart a JOIN srcpart b
+ON a.ds='2008-04-08' and a.hr='11' and b.ds='2008-04-08' and b.hr='12'
+AND a.key = b.key
+
+UNION DISTINCT
+
+select key, value
+FROM srcpart LATERAL VIEW explode(array(1,2,3)) myTable AS myCol
+WHERE ds='2008-04-08' and hr='11'
+) a
+group by key, value
+;
+
+
+SELECT
+count(1) as counts,
+key,
+value
+FROM
+(
+
+SELECT
+a.key, a.value
+FROM srcpart a JOIN srcpart b
+ON a.ds='2008-04-08' and a.hr='11' and b.ds='2008-04-08' and b.hr='12'
+AND a.key = b.key
+
+UNION DISTINCT
+
+select key, value
+FROM srcpart LATERAL VIEW explode(array(1,2,3)) myTable AS myCol
+WHERE ds='2008-04-08' and hr='11'
+) a
+group by key, value
+;
+
+SELECT
+count(1) as counts,
+key,
+value
+FROM
+(
+
+SELECT
+a.key, a.value
+FROM srcpart a JOIN srcpart b
+ON a.ds='2008-04-08' and a.hr='11' and b.ds='2008-04-08' and b.hr='12'
+AND a.key = b.key
+
+UNION DISTINCT
+
+select key, value
+FROM srcpart LATERAL VIEW explode(array(1,2,3)) myTable AS myCol
+WHERE ds='2008-04-08' and hr='11'
+) a
+group by key, value
+;
+-- union27.q
+
+-- SORT_BEFORE_DIFF
+create table jackson_sev_same as select * from src;
+create table dim_pho as select * from src;
+create table jackson_sev_add as select * from src;
+explain select b.* from jackson_sev_same a join (select * from dim_pho UNION DISTINCT select * from jackson_sev_add)b on a.key=b.key and b.key=97;
+select b.* from jackson_sev_same a join (select * from dim_pho UNION DISTINCT select * from jackson_sev_add)b on a.key=b.key and b.key=97;
+-- union28.q
+
+create table union_subq_union(key int, value string);
+
+explain
+insert overwrite table union_subq_union
+select * from (
+ select key, value from src
+ UNION DISTINCT
+ select key, value from
+ (
+ select key, value, count(1) from src group by key, value
+ UNION DISTINCT
+ select key, value, count(1) from src group by key, value
+ ) subq
+) a
+;
+
+insert overwrite table union_subq_union
+select * from (
+ select key, value from src
+ UNION DISTINCT
+ select key, value from
+ (
+ select key, value, count(1) from src group by key, value
+ UNION DISTINCT
+ select key, value, count(1) from src group by key, value
+ ) subq
+) a
+;
+
+select * from union_subq_union order by key, value limit 20;
+-- union29.q
+
+create table union_subq_union29(key int, value string);
+
+explain
+insert overwrite table union_subq_union29
+select * from (
+ select key, value from src
+ UNION DISTINCT
+ select key, value from
+ (
+ select key, value from src
+ UNION DISTINCT
+ select key, value from src
+ ) subq
+) a
+;
+
+insert overwrite table union_subq_union29
+select * from (
+ select key, value from src
+ UNION DISTINCT
+ select key, value from
+ (
+ select key, value from src
+ UNION DISTINCT
+ select key, value from src
+ ) subq
+) a
+;
+
+select * from union_subq_union29 order by key, value limit 20;
+-- union3.q
+
+-- SORT_BEFORE_DIFF
+
+explain
+SELECT *
+FROM (
+ SELECT 1 AS id
+ FROM (SELECT * FROM src LIMIT 1) s1
+ UNION DISTINCT
+ SELECT 2 AS id
+ FROM (SELECT * FROM src LIMIT 1) s1
+ UNION DISTINCT
+ SELECT 3 AS id
+ FROM (SELECT * FROM src LIMIT 1) s2
+ UNION DISTINCT
+ SELECT 4 AS id
+ FROM (SELECT * FROM src LIMIT 1) s2
+ CLUSTER BY id
+) a;
+
+
+
+CREATE TABLE union_out (id int);
+
+insert overwrite table union_out
+SELECT *
+FROM (
+ SELECT 1 AS id
+ FROM (SELECT * FROM src LIMIT 1) s1
+ UNION DISTINCT
+ SELECT 2 AS id
+ FROM (SELECT * FROM src LIMIT 1) s1
+ UNION DISTINCT
+ SELECT 3 AS id
+ FROM (SELECT * FROM src LIMIT 1) s2
+ UNION DISTINCT
+ SELECT 4 AS id
+ FROM (SELECT * FROM src LIMIT 1) s2
+ CLUSTER BY id
+) a;
+
+select * from union_out;
+-- union30.q
+
+create table union_subq_union30(key int, value string);
+
+explain
+insert overwrite table union_subq_union30
+select * from (
+
+select * from (
+ select key, value from src
+ UNION DISTINCT
+ select key, value from
+ (
+ select key, value, count(1) from src group by key, value
+ UNION DISTINCT
+ select key, value, count(1) from src group by key, value
+ ) subq
+) a
+
+UNION DISTINCT
+
+select key, value from src
+) aa
+;
+
+insert overwrite table union_subq_union30
+select * from (
+
+select * from (
+ select key, value from src
+ UNION DISTINCT
+ select key, value from
+ (
+ select key, value, count(1) from src group by key, value
+ UNION DISTINCT
+ select key, value, count(1) from src group by key, value
+ ) subq
+) a
+
+UNION DISTINCT
+
+select key, value from src
+) aa
+;
+
+select * from union_subq_union30 order by key, value limit 20;
+-- union31.q
+
+-- SORT_QUERY_RESULTS
+
+drop table t1;
+drop table t2;
+
+
+create table t1 as select * from src where key < 10;
+create table t2 as select * from src where key < 10;
+
+create table t3(key string, cnt int);
+create table t4(value string, cnt int);
+
+explain
+from
+(select * from t1
+ UNION DISTINCT
+ select * from t2
+) x
+insert overwrite table t3
+ select key, count(1) group by key
+insert overwrite table t4
+ select value, count(1) group by value;
+
+from
+(select * from t1
+ UNION DISTINCT
+ select * from t2
+) x
+insert overwrite table t3
+ select key, count(1) group by key
+insert overwrite table t4
+ select value, count(1) group by value;
+
+select * from t3;
+select * from t4;
+
+create table t5(c1 string, cnt int);
+create table t6(c1 string, cnt int);
+
+explain
+from
+(
+ select key as c1, count(1) as cnt from t1 group by key
+ UNION DISTINCT
+ select key as c1, count(1) as cnt from t2 group by key
+) x
+insert overwrite table t5
+ select c1, sum(cnt) group by c1
+insert overwrite table t6
+ select c1, sum(cnt) group by c1;
+
+from
+(
+ select key as c1, count(1) as cnt from t1 group by key
+ UNION DISTINCT
+ select key as c1, count(1) as cnt from t2 group by key
+) x
+insert overwrite table t5
+ select c1, sum(cnt) group by c1
+insert overwrite table t6
+ select c1, sum(cnt) group by c1;
+
+select * from t5;
+select * from t6;
+
+drop table t1;
+drop table t2;
+
+create table t1 as select * from src where key < 10;
+create table t2 as select key, count(1) as cnt from src where key < 10 group by key;
+
+create table t7(c1 string, cnt int);
+create table t8(c1 string, cnt int);
+
+explain
+from
+(
+ select key as c1, count(1) as cnt from t1 group by key
+ UNION DISTINCT
+ select key as c1, cnt from t2
+) x
+insert overwrite table t7
+ select c1, count(1) group by c1
+insert overwrite table t8
+ select c1, count(1) group by c1;
+
+from
+(
+ select key as c1, count(1) as cnt from t1 group by key
+ UNION DISTINCT
+ select key as c1, cnt from t2
+) x
+insert overwrite table t7
+ select c1, count(1) group by c1
+insert overwrite table t8
+ select c1, count(1) group by c1;
+
+select * from t7;
+select * from t8;
+-- union32.q
+
+-- SORT_QUERY_RESULTS
+
+-- This tests various union queries which have columns on one side of the query
+-- being of double type and those on the other side another
+
+drop table if exists t1;
+
+drop table if exists t2;
+
+CREATE TABLE t1 AS SELECT * FROM src WHERE key < 10;
+CREATE TABLE t2 AS SELECT * FROM src WHERE key < 10;
+
+-- Test simple union with double
+EXPLAIN
+SELECT * FROM
+(SELECT CAST(key AS DOUBLE) AS key FROM t1
+UNION DISTINCT
+SELECT CAST(key AS BIGINT) AS key FROM t2) a
+ORDER BY key;
+
+SELECT * FROM
+(SELECT CAST(key AS DOUBLE) AS key FROM t1
+UNION DISTINCT
+SELECT CAST(key AS BIGINT) AS key FROM t2) a
+;
+
+-- Test union with join on the left
+EXPLAIN
+SELECT * FROM
+(SELECT CAST(a.key AS BIGINT) AS key FROM t1 a JOIN t2 b ON a.key = b.key
+UNION DISTINCT
+SELECT CAST(key AS DOUBLE) AS key FROM t2) a
+;
+
+SELECT * FROM
+(SELECT CAST(a.key AS BIGINT) AS key FROM t1 a JOIN t2 b ON a.key = b.key
+UNION DISTINCT
+SELECT CAST(key AS DOUBLE) AS key FROM t2) a
+;
+
+-- Test union with join on the right
+EXPLAIN
+SELECT * FROM
+(SELECT CAST(key AS DOUBLE) AS key FROM t2
+UNION DISTINCT
+SELECT CAST(a.key AS BIGINT) AS key FROM t1 a JOIN t2 b ON a.key = b.key) a
+;
+
+SELECT * FROM
+(SELECT CAST(key AS DOUBLE) AS key FROM t2
+UNION DISTINCT
+SELECT CAST(a.key AS BIGINT) AS key FROM t1 a JOIN t2 b ON a.key = b.key) a
+;
+
+-- Test union with join on the left selecting multiple columns
+EXPLAIN
+SELECT * FROM
+(SELECT CAST(a.key AS BIGINT) AS key, CAST(b.key AS DOUBLE) AS value FROM t1 a JOIN t2 b ON a.key = b.key
+UNION DISTINCT
+SELECT CAST(key AS DOUBLE) AS key, CAST(key AS STRING) AS value FROM t2) a
+;
+
+SELECT * FROM
+(SELECT CAST(a.key AS BIGINT) AS key, CAST(b.key AS DOUBLE) AS value FROM t1 a JOIN t2 b ON a.key = b.key
+UNION DISTINCT
+SELECT CAST(key AS DOUBLE) AS key, CAST(key AS STRING) AS value FROM t2) a
+;
+
+-- Test union with join on the right selecting multiple columns
+EXPLAIN
+SELECT * FROM
+(SELECT CAST(key AS DOUBLE) AS key, CAST(key AS STRING) AS value FROM t2
+UNION DISTINCT
+SELECT CAST(a.key AS BIGINT) AS key, CAST(b.key AS DOUBLE) AS value FROM t1 a JOIN t2 b ON a.key = b.key) a
+;
+
+SELECT * FROM
+(SELECT CAST(key AS DOUBLE) AS key, CAST(key AS STRING) AS value FROM t2
+UNION DISTINCT
+SELECT CAST(a.key AS BIGINT) AS key, CAST(b.key AS DOUBLE) AS value FROM t1 a JOIN t2 b ON a.key = b.key) a
+;
+-- union33.q
+
+-- SORT_BEFORE_DIFF
+-- This tests that a UNION DISTINCT with a map only subquery on one side and a
+-- subquery involving two map reduce jobs on the other runs correctly.
+
+drop table if exists test_src;
+
+CREATE TABLE test_src (key STRING, value STRING);
+
+EXPLAIN INSERT OVERWRITE TABLE test_src
+SELECT key, value FROM (
+ SELECT key, value FROM src
+ WHERE key = 0
+UNION DISTINCT
+ SELECT key, COUNT(*) AS value FROM src
+ GROUP BY key
+)a;
+
+INSERT OVERWRITE TABLE test_src
+SELECT key, value FROM (
+ SELECT key, value FROM src
+ WHERE key = 0
+UNION DISTINCT
+ SELECT key, COUNT(*) AS value FROM src
+ GROUP BY key
+)a;
+
+SELECT COUNT(*) FROM test_src;
+
+EXPLAIN INSERT OVERWRITE TABLE test_src
+SELECT key, value FROM (
+ SELECT key, COUNT(*) AS value FROM src
+ GROUP BY key
+UNION DISTINCT
+ SELECT key, value FROM src
+ WHERE key = 0
+)a;
+
+INSERT OVERWRITE TABLE test_src
+SELECT key, value FROM (
+ SELECT key, COUNT(*) AS value FROM src
+ GROUP BY key
+UNION DISTINCT
+ SELECT key, value FROM src
+ WHERE key = 0
+)a;
+
+SELECT COUNT(*) FROM test_src;
+ -- union34.q
+
+create table src10_1 (key string, value string);
+create table src10_2 (key string, value string);
+create table src10_3 (key string, value string);
+create table src10_4 (key string, value string);
+
+from (select * from src tablesample (10 rows)) a
+insert overwrite table src10_1 select *
+insert overwrite table src10_2 select *
+insert overwrite table src10_3 select *
+insert overwrite table src10_4 select *;
+
+set hive.auto.convert.join=true;
+-- When we convert the Join of sub1 and sub0 into a MapJoin,
+-- we can use a single MR job to evaluate this entire query.
+explain
+SELECT * FROM (
+ SELECT sub1.key,sub1.value FROM (SELECT * FROM src10_1) sub1 JOIN (SELECT * FROM src10_2) sub0 ON (sub0.key = sub1.key)
+ UNION DISTINCT
+ SELECT key,value FROM (SELECT * FROM (SELECT * FROM src10_3) sub2 UNION DISTINCT SELECT * FROM src10_4 ) alias0
+) alias1 order by key;
+
+SELECT * FROM (
+ SELECT sub1.key,sub1.value FROM (SELECT * FROM src10_1) sub1 JOIN (SELECT * FROM src10_2) sub0 ON (sub0.key = sub1.key)
+ UNION DISTINCT
+ SELECT key,value FROM (SELECT * FROM (SELECT * FROM src10_3) sub2 UNION DISTINCT SELECT * FROM src10_4 ) alias0
+) alias1 order by key;
+
+set hive.auto.convert.join=false;
+-- When we do not convert the Join of sub1 and sub0 into a MapJoin,
+-- we need to use two MR jobs to evaluate this query.
+-- The first job is for the Join of sub1 and sub2. The second job
+-- is for the UNION DISTINCT and ORDER BY.
+explain
+SELECT * FROM (
+ SELECT sub1.key,sub1.value FROM (SELECT * FROM src10_1) sub1 JOIN (SELECT * FROM src10_2) sub0 ON (sub0.key = sub1.key)
+ UNION DISTINCT
+ SELECT key,value FROM (SELECT * FROM (SELECT * FROM src10_3) sub2 UNION DISTINCT SELECT * FROM src10_4 ) alias0
+) alias1 order by key;
+
+SELECT * FROM (
+ SELECT sub1.key,sub1.value FROM (SELECT * FROM src10_1) sub1 JOIN (SELECT * FROM src10_2) sub0 ON (sub0.key = sub1.key)
+ UNION DISTINCT
+ SELECT key,value FROM (SELECT * FROM (SELECT * FROM src10_3) sub2 UNION DISTINCT SELECT * FROM src10_4 ) alias0
+) alias1 order by key;
+-- union4.q
+
+
+
+-- union case: both subqueries are map-reduce jobs on same input, followed by filesink
+
+drop table if exists tmptable;
+
+create table tmptable(key string, value int);
+
+explain
+insert overwrite table tmptable
+ select unionsrc.key, unionsrc.value FROM (select 'tst1' as key, count(1) as value from src s1
+ UNION DISTINCT
+ select 'tst2' as key, count(1) as value from src s2) unionsrc;
+
+insert overwrite table tmptable
+select unionsrc.key, unionsrc.value FROM (select 'tst1' as key, count(1) as value from src s1
+ UNION DISTINCT
+ select 'tst2' as key, count(1) as value from src s2) unionsrc;
+
+select * from tmptable x sort by x.key;
+
+
+-- union5.q
+
+
+-- SORT_BEFORE_DIFF
+-- union case: both subqueries are map-reduce jobs on same input, followed by reduce sink
+
+explain
+ select unionsrc.key, count(1) FROM (select 'tst1' as key, count(1) as value from src s1
+ UNION DISTINCT
+ select 'tst2' as key, count(1) as value from src s2) unionsrc group by unionsrc.key;
+
+select unionsrc.key, count(1) FROM (select 'tst1' as key, count(1) as value from src s1
+ UNION DISTINCT
+ select 'tst2' as key, count(1) as value from src s2) unionsrc group by unionsrc.key;
+-- union6.q
+
+
+
+-- union case: 1 subquery is a map-reduce job, different inputs for sub-queries, followed by filesink
+
+drop table if exists tmptable;
+
+create table tmptable(key string, value string);
+
+explain
+insert overwrite table tmptable
+ select unionsrc.key, unionsrc.value FROM (select 'tst1' as key, cast(count(1) as string) as value from src s1
+ UNION DISTINCT
+ select s2.key as key, s2.value as value from src1 s2) unionsrc;
+
+insert overwrite table tmptable
+select unionsrc.key, unionsrc.value FROM (select 'tst1' as key, cast(count(1) as string) as value from src s1
+ UNION DISTINCT
+ select s2.key as key, s2.value as value from src1 s2) unionsrc;
+
+select * from tmptable x sort by x.key, x.value;
+
+
+-- union7.q
+
+
+
+-- SORT_BEFORE_DIFF
+-- union case: 1 subquery is a map-reduce job, different inputs for sub-queries, followed by reducesink
+
+explain
+ select unionsrc.key, count(1) FROM (select 'tst1' as key, cast(count(1) as string) as value from src s1
+ UNION DISTINCT
+ select s2.key as key, s2.value as value from src1 s2) unionsrc group by unionsrc.key;
+
+select unionsrc.key, count(1) FROM (select 'tst1' as key, cast(count(1) as string) as value from src s1
+ UNION DISTINCT
+ select s2.key as key, s2.value as value from src1 s2) unionsrc group by unionsrc.key;
+
+
+-- union8.q
+
+-- SORT_BEFORE_DIFF
+-- union case: all subqueries are a map-only jobs, 3 way union, same input for all sub-queries, followed by filesink
+
+explain
+ select unionsrc.key, unionsrc.value FROM (select s1.key as key, s1.value as value from src s1 UNION DISTINCT
+ select s2.key as key, s2.value as value from src s2 UNION DISTINCT
+ select s3.key as key, s3.value as value from src s3) unionsrc;
+
+select unionsrc.key, unionsrc.value FROM (select s1.key as key, s1.value as value from src s1 UNION DISTINCT
+ select s2.key as key, s2.value as value from src s2 UNION DISTINCT
+ select s3.key as key, s3.value as value from src s3) unionsrc;
+-- union9.q
+
+-- SORT_BEFORE_DIFF
+-- union case: all subqueries are a map-only jobs, 3 way union, same input for all sub-queries, followed by reducesink
+
+explain
+ select count(1) FROM (select s1.key as key, s1.value as value from src s1 UNION DISTINCT
+ select s2.key as key, s2.value as value from src s2 UNION DISTINCT
+ select s3.key as key, s3.value as value from src s3) unionsrc;
+
+ select count(1) FROM (select s1.key as key, s1.value as value from src s1 UNION DISTINCT
+ select s2.key as key, s2.value as value from src s2 UNION DISTINCT
+ select s3.key as key, s3.value as value from src s3) unionsrc;
Added: hive/trunk/ql/src/test/queries/clientpositive/unionDistinct_2.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/unionDistinct_2.q?rev=1658489&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/unionDistinct_2.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/unionDistinct_2.q Mon Feb 9 18:07:01 2015
@@ -0,0 +1,125 @@
+CREATE TABLE u1 as select key, value from src order by key limit 5;
+
+CREATE TABLE u2 as select key, value from src order by key limit 3;
+
+CREATE TABLE u3 as select key, value from src order by key desc limit 5;
+
+select * from u1;
+
+select * from u2;
+
+select * from u3;
+
+select key, value from
+(
+select key, value from u1
+union all
+select key, value from u2
+union all
+select key as key, value from u3
+) tab;
+
+select key, value from
+(
+select key, value from u1
+union
+select key, value from u2
+union all
+select key, value from u3
+) tab;
+
+select key, value from
+(
+select key, value from u1
+union distinct
+select key, value from u2
+union all
+select key as key, value from u3
+) tab;
+
+select key, value from
+(
+select key, value from u1
+union all
+select key, value from u2
+union
+select key, value from u3
+) tab;
+
+select key, value from
+(
+select key, value from u1
+union
+select key, value from u2
+union
+select key as key, value from u3
+) tab;
+
+select distinct * from
+(
+select key, value from u1
+union all
+select key, value from u2
+union all
+select key as key, value from u3
+) tab;
+
+select distinct * from
+(
+select distinct * from u1
+union
+select key, value from u2
+union all
+select key as key, value from u3
+) tab;
+
+drop view if exists v;
+
+create view v as select distinct * from
+(
+select distinct * from u1
+union
+select key, value from u2
+union all
+select key as key, value from u3
+) tab;
+
+describe extended v;
+
+select * from v;
+
+drop view if exists v;
+
+create view v as select tab.* from
+(
+select distinct * from u1
+union
+select distinct * from u2
+) tab;
+
+describe extended v;
+
+select * from v;
+
+drop view if exists v;
+
+create view v as select * from
+(
+select distinct u1.* from u1
+union all
+select distinct * from u2
+) tab;
+
+describe extended v;
+
+select * from v;
+
+select distinct * from
+(
+select key, value from u1
+union all
+select key, value from u2
+union
+select key as key, value from u3
+) tab;
+
Modified: hive/trunk/ql/src/test/queries/clientpositive/union_null.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/union_null.q?rev=1658489&r1=1658488&r2=1658489&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/union_null.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/union_null.q Mon Feb 9 18:07:01 2015
@@ -1,7 +1,7 @@
-- SORT_BEFORE_DIFF
-- HIVE-2901
-select x from (select value as x from src order by x limit 5 union all select NULL as x from src limit 5) a;
+select x from (select * from (select value as x from src order by x limit 5)a union all select * from (select NULL as x from src limit 5)b )a;
-- HIVE-4837
-select * from (select null as N from src1 group by key UNION ALL select null as N from src1 group by key ) a;
+select * from (select * from (select null as N from src1 group by key)a UNION ALL select * from (select null as N from src1 group by key)b ) a;
Modified: hive/trunk/ql/src/test/queries/clientpositive/union_remove_25.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/union_remove_25.q?rev=1658489&r1=1658488&r2=1658489&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/union_remove_25.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/union_remove_25.q Mon Feb 9 18:07:01 2015
@@ -51,17 +51,17 @@ explain
insert overwrite table outputTbl2 partition(ds)
SELECT *
FROM (
- SELECT key, value, ds from srcpart where ds='2008-04-08' limit 500
+ select * from (SELECT key, value, ds from srcpart where ds='2008-04-08' limit 500)a
UNION ALL
- SELECT key, value, ds from srcpart where ds='2008-04-08' limit 500
+ select * from (SELECT key, value, ds from srcpart where ds='2008-04-08' limit 500)b
) a;
insert overwrite table outputTbl2 partition(ds)
SELECT *
FROM (
- SELECT key, value, ds from srcpart where ds='2008-04-08' limit 500
+ select * from (SELECT key, value, ds from srcpart where ds='2008-04-08' limit 500)a
UNION ALL
- SELECT key, value, ds from srcpart where ds='2008-04-08' limit 500
+ select * from (SELECT key, value, ds from srcpart where ds='2008-04-08' limit 500)b
) a;
show partitions outputTbl2;
@@ -70,17 +70,17 @@ desc formatted outputTbl2 partition(ds='
explain insert overwrite table outputTbl3 partition(ds, hr)
SELECT *
FROM (
- SELECT key, value, ds, hr from srcpart where ds='2008-04-08' limit 1000
+ select * from (SELECT key, value, ds, hr from srcpart where ds='2008-04-08' limit 1000)a
UNION ALL
- SELECT key, value, ds, hr from srcpart where ds='2008-04-08' limit 1000
+ select * from (SELECT key, value, ds, hr from srcpart where ds='2008-04-08' limit 1000)b
) a;
insert overwrite table outputTbl3 partition(ds, hr)
SELECT *
FROM (
- SELECT key, value, ds, hr from srcpart where ds='2008-04-08' limit 1000
+ select * from (SELECT key, value, ds, hr from srcpart where ds='2008-04-08' limit 1000)a
UNION ALL
- SELECT key, value, ds, hr from srcpart where ds='2008-04-08' limit 1000
+ select * from (SELECT key, value, ds, hr from srcpart where ds='2008-04-08' limit 1000)b
) a;
show partitions outputTbl3;
Modified: hive/trunk/ql/src/test/queries/clientpositive/union_top_level.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/union_top_level.q?rev=1658489&r1=1658488&r2=1658489&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/union_top_level.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/union_top_level.q Mon Feb 9 18:07:01 2015
@@ -2,42 +2,42 @@
-- top level
explain
-select key, 0 as value from src where key % 3 == 0 limit 3
+select * from (select key, 0 as value from src where key % 3 == 0 limit 3)a
union all
-select key, 1 as value from src where key % 3 == 1 limit 3
+select * from (select key, 1 as value from src where key % 3 == 1 limit 3)b
union all
-select key, 2 as value from src where key % 3 == 2 limit 3;
+select * from (select key, 2 as value from src where key % 3 == 2 limit 3)c;
-select key, 0 as value from src where key % 3 == 0 limit 3
+select * from (select key, 0 as value from src where key % 3 == 0 limit 3)a
union all
-select key, 1 as value from src where key % 3 == 1 limit 3
+select * from (select key, 1 as value from src where key % 3 == 1 limit 3)b
union all
-select key, 2 as value from src where key % 3 == 2 limit 3;
+select * from (select key, 2 as value from src where key % 3 == 2 limit 3)c;
explain
-select s1.key as k, s2.value as v from src s1 join src s2 on (s1.key = s2.key) limit 10
+select * from (select s1.key as k, s2.value as v from src s1 join src s2 on (s1.key = s2.key) limit 10)a
union all
-select s1.key as k, s2.value as v from src s1 join src s2 on (s1.key = s2.key) limit 10;
+select * from (select s1.key as k, s2.value as v from src s1 join src s2 on (s1.key = s2.key) limit 10)b;
-select s1.key as k, s2.value as v from src s1 join src s2 on (s1.key = s2.key) limit 10
+select * from (select s1.key as k, s2.value as v from src s1 join src s2 on (s1.key = s2.key) limit 10)a
union all
-select s1.key as k, s2.value as v from src s1 join src s2 on (s1.key = s2.key) limit 10;
+select * from (select s1.key as k, s2.value as v from src s1 join src s2 on (s1.key = s2.key) limit 10)b;
-- ctas
explain
create table union_top as
-select key, 0 as value from src where key % 3 == 0 limit 3
+select * from (select key, 0 as value from src where key % 3 == 0 limit 3)a
union all
-select key, 1 as value from src where key % 3 == 1 limit 3
+select * from (select key, 1 as value from src where key % 3 == 1 limit 3)b
union all
-select key, 2 as value from src where key % 3 == 2 limit 3;
+select * from (select key, 2 as value from src where key % 3 == 2 limit 3)c;
create table union_top as
-select key, 0 as value from src where key % 3 == 0 limit 3
+select * from (select key, 0 as value from src where key % 3 == 0 limit 3)a
union all
-select key, 1 as value from src where key % 3 == 1 limit 3
+select * from (select key, 1 as value from src where key % 3 == 1 limit 3)b
union all
-select key, 2 as value from src where key % 3 == 2 limit 3;
+select * from (select key, 2 as value from src where key % 3 == 2 limit 3)c;
select * from union_top;
@@ -46,53 +46,53 @@ truncate table union_top;
-- insert into
explain
insert into table union_top
-select key, 0 as value from src where key % 3 == 0 limit 3
+select * from (select key, 0 as value from src where key % 3 == 0 limit 3)a
union all
-select key, 1 as value from src where key % 3 == 1 limit 3
+select * from (select key, 1 as value from src where key % 3 == 1 limit 3)b
union all
-select key, 2 as value from src where key % 3 == 2 limit 3;
+select * from (select key, 2 as value from src where key % 3 == 2 limit 3)c;
insert into table union_top
-select key, 0 as value from src where key % 3 == 0 limit 3
+select * from (select key, 0 as value from src where key % 3 == 0 limit 3)a
union all
-select key, 1 as value from src where key % 3 == 1 limit 3
+select * from (select key, 1 as value from src where key % 3 == 1 limit 3)b
union all
-select key, 2 as value from src where key % 3 == 2 limit 3;
+select * from (select key, 2 as value from src where key % 3 == 2 limit 3)c;
select * from union_top;
explain
insert overwrite table union_top
-select key, 0 as value from src where key % 3 == 0 limit 3
+select * from (select key, 0 as value from src where key % 3 == 0 limit 3)a
union all
-select key, 1 as value from src where key % 3 == 1 limit 3
+select * from (select key, 1 as value from src where key % 3 == 1 limit 3)b
union all
-select key, 2 as value from src where key % 3 == 2 limit 3;
+select * from (select key, 2 as value from src where key % 3 == 2 limit 3)c;
insert overwrite table union_top
-select key, 0 as value from src where key % 3 == 0 limit 3
+select * from (select key, 0 as value from src where key % 3 == 0 limit 3)a
union all
-select key, 1 as value from src where key % 3 == 1 limit 3
+select * from (select key, 1 as value from src where key % 3 == 1 limit 3)b
union all
-select key, 2 as value from src where key % 3 == 2 limit 3;
+select * from (select key, 2 as value from src where key % 3 == 2 limit 3)c;
select * from union_top;
-- create view
explain
create view union_top_view as
-select key, 0 as value from src where key % 3 == 0 limit 3
+select * from (select key, 0 as value from src where key % 3 == 0 limit 3)a
union all
-select key, 1 as value from src where key % 3 == 1 limit 3
+select * from (select key, 1 as value from src where key % 3 == 1 limit 3)b
union all
-select key, 2 as value from src where key % 3 == 2 limit 3;
+select * from (select key, 2 as value from src where key % 3 == 2 limit 3)c;
create view union_top_view as
-select key, 0 as value from src where key % 3 == 0 limit 3
+select * from (select key, 0 as value from src where key % 3 == 0 limit 3)a
union all
-select key, 1 as value from src where key % 3 == 1 limit 3
+select * from (select key, 1 as value from src where key % 3 == 1 limit 3)b
union all
-select key, 2 as value from src where key % 3 == 2 limit 3;
+select * from (select key, 2 as value from src where key % 3 == 2 limit 3)c;
select * from union_top_view;
Modified: hive/trunk/ql/src/test/queries/clientpositive/vector_multi_insert.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/vector_multi_insert.q?rev=1658489&r1=1658488&r2=1658489&view=diff
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/vector_multi_insert.q (original)
+++ hive/trunk/ql/src/test/queries/clientpositive/vector_multi_insert.q Mon Feb 9 18:07:01 2015
@@ -8,11 +8,11 @@ create table orc1
select rn
from
(
- select cast(1 as int) as rn from src limit 1
+ select * from (select cast(1 as int) as rn from src limit 1)a
union all
- select cast(100 as int) as rn from src limit 1
+ select * from (select cast(100 as int) as rn from src limit 1)b
union all
- select cast(10000 as int) as rn from src limit 1
+ select * from (select cast(10000 as int) as rn from src limit 1)c
) t;
create table orc_rn1 (rn int);
Added: hive/trunk/ql/src/test/results/clientnegative/unionClusterBy.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/unionClusterBy.q.out?rev=1658489&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientnegative/unionClusterBy.q.out (added)
+++ hive/trunk/ql/src/test/results/clientnegative/unionClusterBy.q.out Mon Feb 9 18:07:01 2015
@@ -0,0 +1 @@
+FAILED: ParseException line 6:19 Failed to recognize predicate '<EOF>'. Failed rule: 'orderByClause clusterByClause distributeByClause sortByClause limitClause can only be applied to the whole union.' in statement
Added: hive/trunk/ql/src/test/results/clientnegative/unionDistributeBy.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/unionDistributeBy.q.out?rev=1658489&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientnegative/unionDistributeBy.q.out (added)
+++ hive/trunk/ql/src/test/results/clientnegative/unionDistributeBy.q.out Mon Feb 9 18:07:01 2015
@@ -0,0 +1 @@
+FAILED: ParseException line 6:19 Failed to recognize predicate '<EOF>'. Failed rule: 'orderByClause clusterByClause distributeByClause sortByClause limitClause can only be applied to the whole union.' in statement
Added: hive/trunk/ql/src/test/results/clientnegative/unionLimit.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/unionLimit.q.out?rev=1658489&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientnegative/unionLimit.q.out (added)
+++ hive/trunk/ql/src/test/results/clientnegative/unionLimit.q.out Mon Feb 9 18:07:01 2015
@@ -0,0 +1 @@
+FAILED: ParseException line 6:19 Failed to recognize predicate '<EOF>'. Failed rule: 'orderByClause clusterByClause distributeByClause sortByClause limitClause can only be applied to the whole union.' in statement
Added: hive/trunk/ql/src/test/results/clientnegative/unionOrderBy.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/unionOrderBy.q.out?rev=1658489&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientnegative/unionOrderBy.q.out (added)
+++ hive/trunk/ql/src/test/results/clientnegative/unionOrderBy.q.out Mon Feb 9 18:07:01 2015
@@ -0,0 +1 @@
+FAILED: ParseException line 6:19 Failed to recognize predicate '<EOF>'. Failed rule: 'orderByClause clusterByClause distributeByClause sortByClause limitClause can only be applied to the whole union.' in statement
Added: hive/trunk/ql/src/test/results/clientnegative/unionSortBy.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/unionSortBy.q.out?rev=1658489&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientnegative/unionSortBy.q.out (added)
+++ hive/trunk/ql/src/test/results/clientnegative/unionSortBy.q.out Mon Feb 9 18:07:01 2015
@@ -0,0 +1 @@
+FAILED: ParseException line 6:19 Failed to recognize predicate '<EOF>'. Failed rule: 'orderByClause clusterByClause distributeByClause sortByClause limitClause can only be applied to the whole union.' in statement
Modified: hive/trunk/ql/src/test/results/clientpositive/ba_table_union.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/ba_table_union.q.out?rev=1658489&r1=1658488&r2=1658489&view=diff
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/ba_table_union.q.out (original)
+++ hive/trunk/ql/src/test/results/clientpositive/ba_table_union.q.out Mon Feb 9 18:07:01 2015
@@ -49,9 +49,9 @@ POSTHOOK: Input: default@src
11
12
12
-128
-145
-146
+15
+15
+153
PREHOOK: query: drop table ba_test
PREHOOK: type: DROPTABLE
PREHOOK: Input: default@ba_test
Modified: hive/trunk/ql/src/test/results/clientpositive/cbo_union.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/cbo_union.q.out?rev=1658489&r1=1658488&r2=1658489&view=diff
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/cbo_union.q.out (original)
+++ hive/trunk/ql/src/test/results/clientpositive/cbo_union.q.out Mon Feb 9 18:07:01 2015
@@ -1,7 +1,7 @@
PREHOOK: query: -- SORT_QUERY_RESULTS
-- 11. Union All
-select * from cbo_t1 order by key, c_boolean, value, dt union all select * from cbo_t2 order by key, c_boolean, value, dt
+select * from (select * from cbo_t1 order by key, c_boolean, value, dt)a union all select * from (select * from cbo_t2 order by key, c_boolean, value, dt)b
PREHOOK: type: QUERY
PREHOOK: Input: default@cbo_t1
PREHOOK: Input: default@cbo_t1@dt=2014
@@ -11,7 +11,7 @@ PREHOOK: Input: default@cbo_t2@dt=2014
POSTHOOK: query: -- SORT_QUERY_RESULTS
-- 11. Union All
-select * from cbo_t1 order by key, c_boolean, value, dt union all select * from cbo_t2 order by key, c_boolean, value, dt
+select * from (select * from cbo_t1 order by key, c_boolean, value, dt)a union all select * from (select * from cbo_t2 order by key, c_boolean, value, dt)b
POSTHOOK: type: QUERY
POSTHOOK: Input: default@cbo_t1
POSTHOOK: Input: default@cbo_t1@dt=2014