diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/PTFOperator.java ql/src/java/org/apache/hadoop/hive/ql/exec/PTFOperator.java index 4b267bb..2e6a880 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/PTFOperator.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/PTFOperator.java @@ -337,17 +337,20 @@ void finishPartition() throws HiveException { handleOutputRows(tabFn.finishPartition()); } else { if ( tabFn.canIterateOutput() ) { - outputPartRowsItr = tabFn.iterator(inputPart.iterator()); + outputPartRowsItr = inputPart == null ? null : + tabFn.iterator(inputPart.iterator()); } else { - outputPart = tabFn.execute(inputPart); - outputPartRowsItr = outputPart.iterator(); + outputPart = inputPart == null ? null : tabFn.execute(inputPart); + outputPartRowsItr = outputPart == null ? null : outputPart.iterator(); } if ( next != null ) { if (!next.isStreaming() && !isOutputIterator() ) { next.inputPart = outputPart; } else { - while(outputPartRowsItr.hasNext() ) { - next.processRow(outputPartRowsItr.next()); + if ( outputPartRowsItr != null ) { + while(outputPartRowsItr.hasNext() ) { + next.processRow(outputPartRowsItr.next()); + } } } } @@ -357,8 +360,10 @@ void finishPartition() throws HiveException { next.finishPartition(); } else { if (!isStreaming() ) { - while(outputPartRowsItr.hasNext() ) { - forward(outputPartRowsItr.next(), outputObjInspector); + if ( outputPartRowsItr != null ) { + while(outputPartRowsItr.hasNext() ) { + forward(outputPartRowsItr.next(), outputObjInspector); + } } } } diff --git ql/src/test/queries/clientpositive/ptf_matchpath.q ql/src/test/queries/clientpositive/ptf_matchpath.q index 0cde350..2c1d766 100644 --- ql/src/test/queries/clientpositive/ptf_matchpath.q +++ ql/src/test/queries/clientpositive/ptf_matchpath.q @@ -32,5 +32,15 @@ from matchpath(on arg2('LATE'), arg3(arr_delay > 15), arg4('origin_city_name, fl_num, year, month, day_of_month, size(tpath) as sz, tpath[0].day_of_month as tpath') ) -where fl_num = 1142; +where fl_num = 1142; + +-- 3. empty partition. +select origin_city_name, fl_num, year, month, day_of_month, sz, tpath +from matchpath(on + (select * from flights_tiny where fl_num = -1142) flights_tiny + sort by fl_num, year, month, day_of_month + arg1('LATE.LATE+'), + arg2('LATE'), arg3(arr_delay > 15), + arg4('origin_city_name, fl_num, year, month, day_of_month, size(tpath) as sz, tpath[0].day_of_month as tpath') + ); \ No newline at end of file diff --git ql/src/test/queries/clientpositive/windowing.q ql/src/test/queries/clientpositive/windowing.q index 3f5c3bf..8dceafa 100644 --- ql/src/test/queries/clientpositive/windowing.q +++ ql/src/test/queries/clientpositive/windowing.q @@ -444,3 +444,7 @@ select p_retailprice, avg(p_retailprice) over (partition by p_mfgr order by p_na sum(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following) from part where p_mfgr='Manufacturer#1'; + +-- 47. empty partition +select sum(p_size) over (partition by p_mfgr ) +from part where p_mfgr = 'm1'; diff --git ql/src/test/results/clientpositive/ptf_matchpath.q.out ql/src/test/results/clientpositive/ptf_matchpath.q.out index f04c998..fc0187b 100644 --- ql/src/test/results/clientpositive/ptf_matchpath.q.out +++ ql/src/test/results/clientpositive/ptf_matchpath.q.out @@ -107,3 +107,27 @@ Baltimore 1142 2010 10 21 5 21 Baltimore 1142 2010 10 22 4 22 Baltimore 1142 2010 10 25 3 25 Baltimore 1142 2010 10 26 2 26 +PREHOOK: query: -- 3. empty partition. +select origin_city_name, fl_num, year, month, day_of_month, sz, tpath +from matchpath(on + (select * from flights_tiny where fl_num = -1142) flights_tiny + sort by fl_num, year, month, day_of_month + arg1('LATE.LATE+'), + arg2('LATE'), arg3(arr_delay > 15), + arg4('origin_city_name, fl_num, year, month, day_of_month, size(tpath) as sz, tpath[0].day_of_month as tpath') + ) +PREHOOK: type: QUERY +PREHOOK: Input: default@flights_tiny +#### A masked pattern was here #### +POSTHOOK: query: -- 3. empty partition. +select origin_city_name, fl_num, year, month, day_of_month, sz, tpath +from matchpath(on + (select * from flights_tiny where fl_num = -1142) flights_tiny + sort by fl_num, year, month, day_of_month + arg1('LATE.LATE+'), + arg2('LATE'), arg3(arr_delay > 15), + arg4('origin_city_name, fl_num, year, month, day_of_month, size(tpath) as sz, tpath[0].day_of_month as tpath') + ) +POSTHOOK: type: QUERY +POSTHOOK: Input: default@flights_tiny +#### A masked pattern was here #### diff --git ql/src/test/results/clientpositive/windowing.q.out ql/src/test/results/clientpositive/windowing.q.out index 31d0511..a16e73a 100644 --- ql/src/test/results/clientpositive/windowing.q.out +++ ql/src/test/results/clientpositive/windowing.q.out @@ -2362,3 +2362,15 @@ POSTHOOK: Input: default@part 1602.59 1549.8900000000003 4649.670000000001 1414.42 1523.5400000000004 3047.080000000001 1632.66 1632.6600000000008 1632.6600000000008 +PREHOOK: query: -- 47. empty partition +select sum(p_size) over (partition by p_mfgr ) +from part where p_mfgr = 'm1' +PREHOOK: type: QUERY +PREHOOK: Input: default@part +#### A masked pattern was here #### +POSTHOOK: query: -- 47. empty partition +select sum(p_size) over (partition by p_mfgr ) +from part where p_mfgr = 'm1' +POSTHOOK: type: QUERY +POSTHOOK: Input: default@part +#### A masked pattern was here ####