diff --git data/files/flights_tiny.txt data/files/flights_tiny.txt old mode 100644 new mode 100755 diff --git data/files/part.rc data/files/part.rc old mode 100644 new mode 100755 diff --git data/files/part.seq data/files/part.seq old mode 100644 new mode 100755 diff --git ql/src/java/org/apache/hadoop/hive/ql/parse/WindowingSpec.java ql/src/java/org/apache/hadoop/hive/ql/parse/WindowingSpec.java index e4b959f..769c0c2 100644 --- ql/src/java/org/apache/hadoop/hive/ql/parse/WindowingSpec.java +++ ql/src/java/org/apache/hadoop/hive/ql/parse/WindowingSpec.java @@ -196,8 +196,10 @@ private void inferDefaultWindowingSpec(WindowFunctionSpec wFnSpec) { } private void inferDefaultWindowingSpec(WindowSpec wSpec) { - if ( wSpec == null || wSpec.getPartition() == null || - getSourceOfQueryPartitoningSpec() != null ) { + if ( wSpec == null + || wSpec.getPartition() == null + || getSourceOfQueryPartitoningSpec() != null + || this.getQueryPartitionSpec() != null) { return; } diff --git ql/src/test/queries/clientnegative/ptf_negative_AmbiguousWindowDefn.q ql/src/test/queries/clientnegative/ptf_negative_AmbiguousWindowDefn.q index 593b9fa..49f7858 100644 --- ql/src/test/queries/clientnegative/ptf_negative_AmbiguousWindowDefn.q +++ ql/src/test/queries/clientnegative/ptf_negative_AmbiguousWindowDefn.q @@ -22,7 +22,7 @@ sum(p_size) as s3 over (w3) from part distribute by p_mfgr sort by p_mfgr -window w1 as rows between 2 preceding and 2 following, - w2 as rows between unbounded preceding and current row, +window w1 as (rows between 2 preceding and 2 following), + w2 as (rows between unbounded preceding and current row), w3 as w3; diff --git ql/src/test/queries/clientnegative/ptf_negative_DuplicateWindowAlias.q ql/src/test/queries/clientnegative/ptf_negative_DuplicateWindowAlias.q index 7f50476..5504526 100644 --- ql/src/test/queries/clientnegative/ptf_negative_DuplicateWindowAlias.q +++ ql/src/test/queries/clientnegative/ptf_negative_DuplicateWindowAlias.q @@ -19,6 +19,6 @@ select p_mfgr, p_name, p_size, sum(p_size) as s1 over (w1), sum(p_size) as s2 over (w2) from part -window w1 as distribute by p_mfgr sort by p_mfgr rows between 2 preceding and 2 following, +window w1 as (distribute by p_mfgr sort by p_mfgr rows between 2 preceding and 2 following), w2 as w1, - w2 as rows between unbounded preceding and current row; + w2 as (rows between unbounded preceding and current row); diff --git ql/src/test/queries/clientnegative/ptf_negative_HavingLead.q ql/src/test/queries/clientnegative/ptf_negative_HavingLead.q deleted file mode 100644 index 3b27fe4..0000000 --- ql/src/test/queries/clientnegative/ptf_negative_HavingLead.q +++ /dev/null @@ -1,22 +0,0 @@ -DROP TABLE part; - -CREATE TABLE part( - p_partkey INT, - p_name STRING, - p_mfgr STRING, - p_brand STRING, - p_type STRING, - p_size INT, - p_container STRING, - p_retailprice DOUBLE, - p_comment STRING -); - -LOAD DATA LOCAL INPATH '../data/files/part_tiny.txt' overwrite into table part; - --- testHavingLead -select p_mfgr,p_name, p_size -from part -having lead(p_size, 1) <= p_size -distribute by p_mfgr -sort by p_name; \ No newline at end of file diff --git ql/src/test/queries/clientnegative/ptf_negative_HavingLeadWithNoGBYNoWindowing.q ql/src/test/queries/clientnegative/ptf_negative_HavingLeadWithNoGBYNoWindowing.q new file mode 100644 index 0000000..b4e0ea3 --- /dev/null +++ ql/src/test/queries/clientnegative/ptf_negative_HavingLeadWithNoGBYNoWindowing.q @@ -0,0 +1,22 @@ +DROP TABLE part; + +CREATE TABLE part( + p_partkey INT, + p_name STRING, + p_mfgr STRING, + p_brand STRING, + p_type STRING, + p_size INT, + p_container STRING, + p_retailprice DOUBLE, + p_comment STRING +); + +LOAD DATA LOCAL INPATH '../data/files/part_tiny.txt' overwrite into table part; + +-- testHavingLeadWithNoGBYNoWindowing +select p_mfgr,p_name, p_size +from part +having lead(p_size, 1) <= p_size +distribute by p_mfgr +sort by p_name; diff --git ql/src/test/queries/clientnegative/ptf_negative_IncompatibleDistributeClause.q ql/src/test/queries/clientnegative/ptf_negative_IncompatibleDistributeClause.q index 9229c14..bbcf298 100644 --- ql/src/test/queries/clientnegative/ptf_negative_IncompatibleDistributeClause.q +++ ql/src/test/queries/clientnegative/ptf_negative_IncompatibleDistributeClause.q @@ -16,8 +16,8 @@ LOAD DATA LOCAL INPATH '../data/files/part_tiny.txt' overwrite into table part; -- testIncompatibleDistributeClause select p_mfgr,p_name, p_size, -rank() as r, denserank() as dr, +rank() as r, dense_rank() as dr, sum(p_size) as s over (w1) from part distribute by p_mfgr -window w1 as distribute by p_name rows between 2 preceding and 2 following; \ No newline at end of file +window w1 as (distribute by p_name rows between 2 preceding and 2 following); \ No newline at end of file diff --git ql/src/test/queries/clientnegative/ptf_negative_IncompatibleOrderInWindowDefs.q ql/src/test/queries/clientnegative/ptf_negative_IncompatibleOrderInWindowDefs.q index 1cfa650..85db66f 100644 --- ql/src/test/queries/clientnegative/ptf_negative_IncompatibleOrderInWindowDefs.q +++ ql/src/test/queries/clientnegative/ptf_negative_IncompatibleOrderInWindowDefs.q @@ -21,5 +21,5 @@ sum(p_size) as s2 over (w2) from part distribute by p_mfgr sort by p_mfgr -window w1 as distribute by p_mfgr sort by p_mfgr rows between 2 preceding and 2 following, - w2 as distribute by p_mfgr sort by p_name rows between unbounded preceding and current row; +window w1 as (distribute by p_mfgr sort by p_mfgr rows between 2 preceding and 2 following), + w2 as (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row); diff --git ql/src/test/queries/clientnegative/ptf_negative_IncompatiblePartitionInWindowDefs.q ql/src/test/queries/clientnegative/ptf_negative_IncompatiblePartitionInWindowDefs.q index 670a162..2a00560 100644 --- ql/src/test/queries/clientnegative/ptf_negative_IncompatiblePartitionInWindowDefs.q +++ ql/src/test/queries/clientnegative/ptf_negative_IncompatiblePartitionInWindowDefs.q @@ -21,5 +21,5 @@ sum(p_size) as s2 over (w2) from part distribute by p_mfgr sort by p_mfgr -window w1 as distribute by p_mfgr sort by p_mfgr rows between 2 preceding and 2 following, - w2 as distribute by p_name sort by p_name rows between unbounded preceding and current row; +window w1 as (distribute by p_mfgr sort by p_mfgr rows between 2 preceding and 2 following), + w2 as (distribute by p_name sort by p_name rows between unbounded preceding and current row); diff --git ql/src/test/queries/clientnegative/ptf_negative_IncompatibleSortClause.q ql/src/test/queries/clientnegative/ptf_negative_IncompatibleSortClause.q index af567c0..fa962ac 100644 --- ql/src/test/queries/clientnegative/ptf_negative_IncompatibleSortClause.q +++ ql/src/test/queries/clientnegative/ptf_negative_IncompatibleSortClause.q @@ -16,8 +16,8 @@ LOAD DATA LOCAL INPATH '../data/files/part_tiny.txt' overwrite into table part; -- testIncompatibleSortClause select p_mfgr,p_name, p_size, -rank() as r, denserank() as dr, +rank() as r, dense_rank() as dr, sum(p_size) as s over (w1) from part distribute by p_mfgr -window w1 as distribute by p_mfgr sort by p_name rows between 2 preceding and 2 following; \ No newline at end of file +window w1 as (distribute by p_mfgr sort by p_name rows between 2 preceding and 2 following); \ No newline at end of file diff --git ql/src/test/queries/clientnegative/ptf_negative_InvalidValueBoundary.q ql/src/test/queries/clientnegative/ptf_negative_InvalidValueBoundary.q index 1003266..90827aa 100644 --- ql/src/test/queries/clientnegative/ptf_negative_InvalidValueBoundary.q +++ ql/src/test/queries/clientnegative/ptf_negative_InvalidValueBoundary.q @@ -17,8 +17,8 @@ LOAD DATA LOCAL INPATH '../data/files/part_tiny.txt' overwrite into table part; -- testInvalidValueBoundary select p_mfgr,p_name, p_size, sum(p_size) as s over (w1) , -denserank() as dr +dense_rank() as dr from part distribute by p_mfgr sort by p_name -window w1 as range between p_name 2 less and current row; \ No newline at end of file +window w1 as (range between p_name 2 less and current row); \ No newline at end of file diff --git ql/src/test/queries/clientnegative/ptf_negative_NoSortNoDistByClause.q ql/src/test/queries/clientnegative/ptf_negative_NoSortNoDistByClause.q index fe05ab9..ef617a9 100644 --- ql/src/test/queries/clientnegative/ptf_negative_NoSortNoDistByClause.q +++ ql/src/test/queries/clientnegative/ptf_negative_NoSortNoDistByClause.q @@ -16,6 +16,6 @@ LOAD DATA LOCAL INPATH '../data/files/part_tiny.txt' overwrite into table part; -- testNoSortNoDistByClause select p_mfgr,p_name, p_size, -rank() as r, denserank() as dr +rank() as r, dense_rank() as dr from part -window w1 as rows between 2 preceding and 2 following; \ No newline at end of file +window w1 as (rows between 2 preceding and 2 following); \ No newline at end of file diff --git ql/src/test/queries/clientnegative/ptf_negative_WhereLead.q ql/src/test/queries/clientnegative/ptf_negative_WhereLead.q deleted file mode 100644 index 38cbb7d..0000000 --- ql/src/test/queries/clientnegative/ptf_negative_WhereLead.q +++ /dev/null @@ -1,22 +0,0 @@ -DROP TABLE part; - -CREATE TABLE part( - p_partkey INT, - p_name STRING, - p_mfgr STRING, - p_brand STRING, - p_type STRING, - p_size INT, - p_container STRING, - p_retailprice DOUBLE, - p_comment STRING -); - -LOAD DATA LOCAL INPATH '../data/files/part_tiny.txt' overwrite into table part; - --- testWhereLead -select p_mfgr,p_name, p_size -from part -where lead(p_size, 1) <= p_size -distribute by p_mfgr -sort by p_name; diff --git ql/src/test/results/clientnegative/ptf_negative_AggrFuncsWithNoGBYNoPartDef.q.out ql/src/test/results/clientnegative/ptf_negative_AggrFuncsWithNoGBYNoPartDef.q.out index 81d37f5..e1355b3 100644 --- ql/src/test/results/clientnegative/ptf_negative_AggrFuncsWithNoGBYNoPartDef.q.out +++ ql/src/test/results/clientnegative/ptf_negative_AggrFuncsWithNoGBYNoPartDef.q.out @@ -33,4 +33,4 @@ PREHOOK: Output: default@part POSTHOOK: query: LOAD DATA LOCAL INPATH '../data/files/part_tiny.txt' overwrite into table part POSTHOOK: type: LOAD POSTHOOK: Output: default@part -FAILED: SemanticException 6:5 No partition specification associated with start of PTF chain . Error encountered near token 's1' +FAILED: SemanticException 6:5 No partition specification associated with Windowing . Error encountered near token 's1' diff --git ql/src/test/results/clientnegative/ptf_negative_AmbiguousWindowDefn.q.out ql/src/test/results/clientnegative/ptf_negative_AmbiguousWindowDefn.q.out index ee473b9..cc02d3b 100644 --- ql/src/test/results/clientnegative/ptf_negative_AmbiguousWindowDefn.q.out +++ ql/src/test/results/clientnegative/ptf_negative_AmbiguousWindowDefn.q.out @@ -33,4 +33,4 @@ PREHOOK: Output: default@part POSTHOOK: query: LOAD DATA LOCAL INPATH '../data/files/part_tiny.txt' overwrite into table part POSTHOOK: type: LOAD POSTHOOK: Output: default@part -FAILED: SemanticException Window Spec w3 refers to an unknown source +FAILED: SemanticException Cycle in Window references [w3, w3] diff --git ql/src/test/results/clientnegative/ptf_negative_HavingLead.q.out ql/src/test/results/clientnegative/ptf_negative_HavingLead.q.out deleted file mode 100644 index 1d5594d..0000000 --- ql/src/test/results/clientnegative/ptf_negative_HavingLead.q.out +++ /dev/null @@ -1,36 +0,0 @@ -PREHOOK: query: DROP TABLE part -PREHOOK: type: DROPTABLE -POSTHOOK: query: DROP TABLE part -POSTHOOK: type: DROPTABLE -PREHOOK: query: CREATE TABLE part( - p_partkey INT, - p_name STRING, - p_mfgr STRING, - p_brand STRING, - p_type STRING, - p_size INT, - p_container STRING, - p_retailprice DOUBLE, - p_comment STRING -) -PREHOOK: type: CREATETABLE -POSTHOOK: query: CREATE TABLE part( - p_partkey INT, - p_name STRING, - p_mfgr STRING, - p_brand STRING, - p_type STRING, - p_size INT, - p_container STRING, - p_retailprice DOUBLE, - p_comment STRING -) -POSTHOOK: type: CREATETABLE -POSTHOOK: Output: default@part -PREHOOK: query: LOAD DATA LOCAL INPATH '../data/files/part_tiny.txt' overwrite into table part -PREHOOK: type: LOAD -PREHOOK: Output: default@part -POSTHOOK: query: LOAD DATA LOCAL INPATH '../data/files/part_tiny.txt' overwrite into table part -POSTHOOK: type: LOAD -POSTHOOK: Output: default@part -FAILED: SemanticException 6:23 Query has no windowing or group by clause: Unsupported place for having. Error encountered near token 'p_size' diff --git ql/src/test/results/clientnegative/ptf_negative_HavingLeadWithNoGBYNoWindowing.q.out ql/src/test/results/clientnegative/ptf_negative_HavingLeadWithNoGBYNoWindowing.q.out new file mode 100644 index 0000000..1d5594d --- /dev/null +++ ql/src/test/results/clientnegative/ptf_negative_HavingLeadWithNoGBYNoWindowing.q.out @@ -0,0 +1,36 @@ +PREHOOK: query: DROP TABLE part +PREHOOK: type: DROPTABLE +POSTHOOK: query: DROP TABLE part +POSTHOOK: type: DROPTABLE +PREHOOK: query: CREATE TABLE part( + p_partkey INT, + p_name STRING, + p_mfgr STRING, + p_brand STRING, + p_type STRING, + p_size INT, + p_container STRING, + p_retailprice DOUBLE, + p_comment STRING +) +PREHOOK: type: CREATETABLE +POSTHOOK: query: CREATE TABLE part( + p_partkey INT, + p_name STRING, + p_mfgr STRING, + p_brand STRING, + p_type STRING, + p_size INT, + p_container STRING, + p_retailprice DOUBLE, + p_comment STRING +) +POSTHOOK: type: CREATETABLE +POSTHOOK: Output: default@part +PREHOOK: query: LOAD DATA LOCAL INPATH '../data/files/part_tiny.txt' overwrite into table part +PREHOOK: type: LOAD +PREHOOK: Output: default@part +POSTHOOK: query: LOAD DATA LOCAL INPATH '../data/files/part_tiny.txt' overwrite into table part +POSTHOOK: type: LOAD +POSTHOOK: Output: default@part +FAILED: SemanticException 6:23 Query has no windowing or group by clause: Unsupported place for having. Error encountered near token 'p_size' diff --git ql/src/test/results/clientnegative/ptf_negative_IncompatibleDistributeClause.q.out ql/src/test/results/clientnegative/ptf_negative_IncompatibleDistributeClause.q.out index 9a50c4d..80866d2 100644 --- ql/src/test/results/clientnegative/ptf_negative_IncompatibleDistributeClause.q.out +++ ql/src/test/results/clientnegative/ptf_negative_IncompatibleDistributeClause.q.out @@ -33,4 +33,4 @@ PREHOOK: Output: default@part POSTHOOK: query: LOAD DATA LOCAL INPATH '../data/files/part_tiny.txt' overwrite into table part POSTHOOK: type: LOAD POSTHOOK: Output: default@part -FAILED: SemanticException Window Function 'sum((TOK_TABLE_OR_COL p_size)) w1 partitionColumns=[(TOK_TABLE_OR_COL p_name)] window(start=range(2 PRECEDING), end=range(2 FOLLOWING)) as s' has an incompatible partition clause +FAILED: SemanticException Window Function 'sum' has an incompatible partition clause diff --git ql/src/test/results/clientnegative/ptf_negative_IncompatibleOrderInWindowDefs.q.out ql/src/test/results/clientnegative/ptf_negative_IncompatibleOrderInWindowDefs.q.out index df00a35..899c855 100644 --- ql/src/test/results/clientnegative/ptf_negative_IncompatibleOrderInWindowDefs.q.out +++ ql/src/test/results/clientnegative/ptf_negative_IncompatibleOrderInWindowDefs.q.out @@ -33,4 +33,4 @@ PREHOOK: Output: default@part POSTHOOK: query: LOAD DATA LOCAL INPATH '../data/files/part_tiny.txt' overwrite into table part POSTHOOK: type: LOAD POSTHOOK: Output: default@part -FAILED: SemanticException Window Function 'sum((TOK_TABLE_OR_COL p_size)) w2 partitionColumns=[(TOK_TABLE_OR_COL p_mfgr)] orderColumns=[(TOK_TABLE_OR_COL p_name) ASC] window(start=range(Unbounded PRECEDING), end=currentRow) as s2' has an incompatible order clause +FAILED: SemanticException Window Function 'sum' has an incompatible order clause diff --git ql/src/test/results/clientnegative/ptf_negative_IncompatiblePartitionInWindowDefs.q.out ql/src/test/results/clientnegative/ptf_negative_IncompatiblePartitionInWindowDefs.q.out index e9b943b..80866d2 100644 --- ql/src/test/results/clientnegative/ptf_negative_IncompatiblePartitionInWindowDefs.q.out +++ ql/src/test/results/clientnegative/ptf_negative_IncompatiblePartitionInWindowDefs.q.out @@ -33,4 +33,4 @@ PREHOOK: Output: default@part POSTHOOK: query: LOAD DATA LOCAL INPATH '../data/files/part_tiny.txt' overwrite into table part POSTHOOK: type: LOAD POSTHOOK: Output: default@part -FAILED: SemanticException Window Function 'sum((TOK_TABLE_OR_COL p_size)) w2 partitionColumns=[(TOK_TABLE_OR_COL p_name)] orderColumns=[(TOK_TABLE_OR_COL p_name) ASC] window(start=range(Unbounded PRECEDING), end=currentRow) as s2' has an incompatible partition clause +FAILED: SemanticException Window Function 'sum' has an incompatible partition clause diff --git ql/src/test/results/clientnegative/ptf_negative_IncompatibleSortClause.q.out ql/src/test/results/clientnegative/ptf_negative_IncompatibleSortClause.q.out index 529f19f..899c855 100644 --- ql/src/test/results/clientnegative/ptf_negative_IncompatibleSortClause.q.out +++ ql/src/test/results/clientnegative/ptf_negative_IncompatibleSortClause.q.out @@ -33,4 +33,4 @@ PREHOOK: Output: default@part POSTHOOK: query: LOAD DATA LOCAL INPATH '../data/files/part_tiny.txt' overwrite into table part POSTHOOK: type: LOAD POSTHOOK: Output: default@part -FAILED: SemanticException Window Function 'sum((TOK_TABLE_OR_COL p_size)) w1 partitionColumns=[(TOK_TABLE_OR_COL p_mfgr)] orderColumns=[(TOK_TABLE_OR_COL p_name) ASC] window(start=range(2 PRECEDING), end=range(2 FOLLOWING)) as s' has an incompatible order clause +FAILED: SemanticException Window Function 'sum' has an incompatible order clause diff --git ql/src/test/results/clientnegative/ptf_negative_NoSortNoDistByClause.q.out ql/src/test/results/clientnegative/ptf_negative_NoSortNoDistByClause.q.out index 4f241a4..7a03a35 100644 --- ql/src/test/results/clientnegative/ptf_negative_NoSortNoDistByClause.q.out +++ ql/src/test/results/clientnegative/ptf_negative_NoSortNoDistByClause.q.out @@ -33,4 +33,4 @@ PREHOOK: Output: default@part POSTHOOK: query: LOAD DATA LOCAL INPATH '../data/files/part_tiny.txt' overwrite into table part POSTHOOK: type: LOAD POSTHOOK: Output: default@part -FAILED: SemanticException 6:5 No partition specification associated with start of PTF chain . Error encountered near token '2' +FAILED: SemanticException 6:5 No partition specification associated with Windowing . Error encountered near token '2' diff --git ql/src/test/results/clientnegative/ptf_negative_WhereLead.q.out ql/src/test/results/clientnegative/ptf_negative_WhereLead.q.out deleted file mode 100644 index d490b7b..0000000 --- ql/src/test/results/clientnegative/ptf_negative_WhereLead.q.out +++ /dev/null @@ -1,55 +0,0 @@ -PREHOOK: query: DROP TABLE part -PREHOOK: type: DROPTABLE -POSTHOOK: query: DROP TABLE part -POSTHOOK: type: DROPTABLE -PREHOOK: query: CREATE TABLE part( - p_partkey INT, - p_name STRING, - p_mfgr STRING, - p_brand STRING, - p_type STRING, - p_size INT, - p_container STRING, - p_retailprice DOUBLE, - p_comment STRING -) -PREHOOK: type: CREATETABLE -POSTHOOK: query: CREATE TABLE part( - p_partkey INT, - p_name STRING, - p_mfgr STRING, - p_brand STRING, - p_type STRING, - p_size INT, - p_container STRING, - p_retailprice DOUBLE, - p_comment STRING -) -POSTHOOK: type: CREATETABLE -POSTHOOK: Output: default@part -PREHOOK: query: LOAD DATA LOCAL INPATH '../data/files/part_tiny.txt' overwrite into table part -PREHOOK: type: LOAD -PREHOOK: Output: default@part -POSTHOOK: query: LOAD DATA LOCAL INPATH '../data/files/part_tiny.txt' overwrite into table part -POSTHOOK: type: LOAD -POSTHOOK: Output: default@part -PREHOOK: query: -- testWhereLead -select p_mfgr,p_name, p_size -from part -where lead(p_size, 1) <= p_size -distribute by p_mfgr -sort by p_name -PREHOOK: type: QUERY -PREHOOK: Input: default@part -#### A masked pattern was here #### -Execution failed with exit status: 2 -Obtaining error information - -Task failed! -Task ID: - Stage-1 - -Logs: - -#### A masked pattern was here #### -FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.MapRedTask