diff --git common/src/java/org/apache/hadoop/hive/conf/HiveConf.java common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
index 1e2007b..2b381de 100644
--- common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
+++ common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
@@ -606,6 +606,10 @@
HIVEOPTSORTMERGEBUCKETMAPJOIN("hive.optimize.bucketmapjoin.sortedmerge", false), // try to use sorted merge bucket map join
HIVEOPTREDUCEDEDUPLICATION("hive.optimize.reducededuplication", true),
HIVEOPTREDUCEDEDUPLICATIONMINREDUCER("hive.optimize.reducededuplication.min.reducer", 4),
+ // when enabled dynamic partitioning column will be globally sorted.
+ // this way we can keep only one record writer open for each partition value
+ // in the reducer thereby reducing the memory pressure on reducers
+ HIVEOPTSORTDYNAMICPARTITION("hive.optimize.sort.dynamic.partition", true),
HIVESAMPLINGFORORDERBY("hive.optimize.sampling.orderby", false),
HIVESAMPLINGNUMBERFORORDERBY("hive.optimize.sampling.orderby.number", 1000),
diff --git conf/hive-default.xml.template conf/hive-default.xml.template
index 8aaf3a0..4a09c24 100644
--- conf/hive-default.xml.template
+++ conf/hive-default.xml.template
@@ -503,6 +503,14 @@
+ hive.optimize.sort.dynamic.partition
+ true
+ When enabled dynamic partitioning column will be globally sorted.
+ This way we can keep only one record writer open for each partition value
+ in the reducer thereby reducing the memory pressure on reducers.
+
+
+
hive.optimize.skewjoin.compiletime
false
Whether to create a separate plan for skewed keys for the tables in the join.
diff --git itests/qtest/pom.xml itests/qtest/pom.xml
index e17218c..f79fe53 100644
--- itests/qtest/pom.xml
+++ itests/qtest/pom.xml
@@ -39,7 +39,7 @@
stats_counter_partitioned.q,list_bucket_dml_10.q,input16_cc.q,scriptfile1.q,scriptfile1_win.q,bucket4.q,bucketmapjoin6.q,disable_merge_for_bucketing.q,reduce_deduplicate.q,smb_mapjoin_8.q,join1.q,groupby2.q,bucketizedhiveinputformat.q,bucketmapjoin7.q,optrstat_groupby.q,bucket_num_reducers.q,bucket5.q,load_fs2.q,bucket_num_reducers2.q,infer_bucket_sort_merge.q,infer_bucket_sort_reducers_power_two.q,infer_bucket_sort_dyn_part.q,infer_bucket_sort_bucketed_table.q,infer_bucket_sort_map_operators.q,infer_bucket_sort_num_buckets.q,leftsemijoin_mr.q,schemeAuthority.q,schemeAuthority2.q,truncate_column_buckets.q,remote_script.q,,load_hdfs_file_with_space_in_the_name.q,parallel_orderby.q,import_exported_table.q,stats_counter.q,auto_sortmerge_join_16.q,quotedid_smb.q,file_with_header_footer.q,external_table_with_space_in_location_path.q,root_dir_external_table.q,index_bitmap3.q,ql_rewrite_gbtoidx.q,index_bitmap_auto.q,udf_using.q
cluster_tasklog_retrieval.q,minimr_broken_pipe.q,mapreduce_stack_trace.q,mapreduce_stack_trace_turnoff.q,mapreduce_stack_trace_hadoop20.q,mapreduce_stack_trace_turnoff_hadoop20.q,file_with_header_footer_negative.q,udf_local_resource.q
mapjoin_decimal.q,tez_join_tests.q,tez_joins_explain.q,mrr.q,tez_dml.q,tez_insert_overwrite_local_directory_1.q,tez_union.q
- orc_analyze.q,join0.q,join1.q,auto_join0.q,auto_join1.q,bucket2.q,bucket3.q,bucket4.q,count.q,create_merge_compressed.q,cross_join.q,ctas.q,custom_input_output_format.q,disable_merge_for_bucketing.q,enforce_order.q,filter_join_breaktask.q,filter_join_breaktask2.q,groupby1.q,groupby2.q,groupby3.q,having.q,insert1.q,insert_into1.q,insert_into2.q,leftsemijoin.q,limit_pushdown.q,load_dyn_part1.q,load_dyn_part2.q,load_dyn_part3.q,mapjoin_mapjoin.q,mapreduce1.q,mapreduce2.q,merge1.q,merge2.q,metadata_only_queries.q,sample1.q,subquery_in.q,subquery_exists.q,vectorization_15.q,ptf.q,stats_counter.q,stats_noscan_1.q,stats_counter_partitioned.q,union2.q,union3.q,union4.q,union5.q,union6.q,union7.q,union8.q,union9.q
+ dynpart_sort_optimization.q,orc_analyze.q,join0.q,join1.q,auto_join0.q,auto_join1.q,bucket2.q,bucket3.q,bucket4.q,count.q,create_merge_compressed.q,cross_join.q,ctas.q,custom_input_output_format.q,disable_merge_for_bucketing.q,enforce_order.q,filter_join_breaktask.q,filter_join_breaktask2.q,groupby1.q,groupby2.q,groupby3.q,having.q,insert1.q,insert_into1.q,insert_into2.q,leftsemijoin.q,limit_pushdown.q,load_dyn_part1.q,load_dyn_part2.q,load_dyn_part3.q,mapjoin_mapjoin.q,mapreduce1.q,mapreduce2.q,merge1.q,merge2.q,metadata_only_queries.q,sample1.q,subquery_in.q,subquery_exists.q,vectorization_15.q,ptf.q,stats_counter.q,stats_noscan_1.q,stats_counter_partitioned.q,union2.q,union3.q,union4.q,union5.q,union6.q,union7.q,union8.q,union9.q
add_part_exist.q,alter1.q,alter2.q,alter4.q,alter5.q,alter_rename_partition.q,alter_rename_partition_authorization.q,archive.q,archive_corrupt.q,archive_multi.q,archive_mr_1806.q,archive_multi_mr_1806.q,authorization_1.q,authorization_2.q,authorization_4.q,authorization_5.q,authorization_6.q,authorization_7.q,ba_table1.q,ba_table2.q,ba_table3.q,ba_table_udfs.q,binary_table_bincolserde.q,binary_table_colserde.q,cluster.q,columnarserde_create_shortcut.q,combine2.q,constant_prop.q,create_nested_type.q,create_or_replace_view.q,create_struct_table.q,create_union_table.q,database.q,database_location.q,database_properties.q,ddltime.q,describe_database_json.q,drop_database_removes_partition_dirs.q,escape1.q,escape2.q,exim_00_nonpart_empty.q,exim_01_nonpart.q,exim_02_00_part_empty.q,exim_02_part.q,exim_03_nonpart_over_compat.q,exim_04_all_part.q,exim_04_evolved_parts.q,exim_05_some_part.q,exim_06_one_part.q,exim_07_all_part_over_nonoverlap.q,exim_08_nonpart_rename.q,exim_09_part_spec_nonoverlap.q,exim_10_external_managed.q,exim_11_managed_external.q,exim_12_external_location.q,exim_13_managed_location.q,exim_14_managed_location_over_existing.q,exim_15_external_part.q,exim_16_part_external.q,exim_17_part_managed.q,exim_18_part_external.q,exim_19_00_part_external_location.q,exim_19_part_external_location.q,exim_20_part_managed_location.q,exim_21_export_authsuccess.q,exim_22_import_exist_authsuccess.q,exim_23_import_part_authsuccess.q,exim_24_import_nonexist_authsuccess.q,global_limit.q,groupby_complex_types.q,groupby_complex_types_multi_single_reducer.q,index_auth.q,index_auto.q,index_auto_empty.q,index_bitmap.q,index_bitmap1.q,index_bitmap2.q,index_bitmap3.q,index_bitmap_auto.q,index_bitmap_rc.q,index_compact.q,index_compact_1.q,index_compact_2.q,index_compact_3.q,index_stale_partitioned.q,init_file.q,input16.q,input16_cc.q,input46.q,input_columnarserde.q,input_dynamicserde.q,input_lazyserde.q,input_testxpath3.q,input_testxpath4.q,insert2_overwrite_partitions.q,insertexternal1.q,join_thrift.q,lateral_view.q,load_binary_data.q,load_exist_part_authsuccess.q,load_nonpart_authsuccess.q,load_part_authsuccess.q,loadpart_err.q,lock1.q,lock2.q,lock3.q,lock4.q,merge_dynamic_partition.q,multi_insert.q,multi_insert_move_tasks_share_dependencies.q,null_column.q,ppd_clusterby.q,query_with_semi.q,rename_column.q,sample6.q,sample_islocalmode_hook.q,set_processor_namespaces.q,show_tables.q,source.q,split_sample.q,str_to_map.q,transform1.q,udaf_collect_set.q,udaf_context_ngrams.q,udaf_histogram_numeric.q,udaf_ngrams.q,udaf_percentile_approx.q,udf_array.q,udf_bitmap_and.q,udf_bitmap_or.q,udf_explode.q,udf_format_number.q,udf_map.q,udf_map_keys.q,udf_map_values.q,udf_max.q,udf_min.q,udf_named_struct.q,udf_percentile.q,udf_printf.q,udf_sentences.q,udf_sort_array.q,udf_split.q,udf_struct.q,udf_substr.q,udf_translate.q,udf_union.q,udf_xpath.q,udtf_stack.q,view.q,virtual_column.q
diff --git itests/qtest/ql/src/test/queries/clientpositive/dynpart_sort_optimization.q itests/qtest/ql/src/test/queries/clientpositive/dynpart_sort_optimization.q
new file mode 100644
index 0000000..5d17359
--- /dev/null
+++ itests/qtest/ql/src/test/queries/clientpositive/dynpart_sort_optimization.q
@@ -0,0 +1,89 @@
+set hive.optimize.sort.dynamic.partition=true;
+set hive.exec.dynamic.partition=true;
+set hive.exec.max.dynamic.partitions=1000;
+set hive.exec.max.dynamic.partitions.pernode=1000;
+set hive.exec.dynamic.partition.mode=nonstrict;
+set hive.enforce.bucketing=false;
+set hive.enforce.sorting=false;
+
+create table over1k(
+ t tinyint,
+ si smallint,
+ i int,
+ b bigint,
+ f float,
+ d double,
+ bo boolean,
+ s string,
+ ts timestamp,
+ dec decimal(4,2),
+ bin binary)
+ row format delimited
+ fields terminated by '|';
+
+load data local inpath '../../data/files/over1k' into table over1k;
+
+create table over1k_part(
+ si smallint,
+ i int,
+ b bigint,
+ f float)
+ partitioned by (ds string, t tinyint);
+
+create table over1k_part_limit like over1k_part;
+
+create table over1k_part_buck(
+ si smallint,
+ i int,
+ b bigint,
+ f float)
+ partitioned by (t tinyint)
+ clustered by (si) into 4 buckets;
+
+create table over1k_part_buck_sort(
+ si smallint,
+ i int,
+ b bigint,
+ f float)
+ partitioned by (t tinyint)
+ clustered by (si)
+ sorted by (f) into 4 buckets;
+
+-- map-only jobs converted to map-reduce job by hive.optimize.sort.dynamic.partition optimization
+explain insert overwrite table over1k_part partition(ds="foo", t) select si,i,b,f,t from over1k where t is null or t=27;
+explain insert overwrite table over1k_part_limit partition(ds="foo", t) select si,i,b,f,t from over1k where t is null or t=27 limit 10;
+explain insert overwrite table over1k_part_buck partition(t) select si,i,b,f,t from over1k where t is null or t=27;
+explain insert overwrite table over1k_part_buck_sort partition(t) select si,i,b,f,t from over1k where t is null or t=27;
+
+insert overwrite table over1k_part partition(ds="foo", t) select si,i,b,f,t from over1k where t is null or t=27;
+insert overwrite table over1k_part_limit partition(ds="foo", t) select si,i,b,f,t from over1k where t is null or t=27 limit 10;
+insert overwrite table over1k_part_buck partition(t) select si,i,b,f,t from over1k where t is null or t=27;
+insert overwrite table over1k_part_buck_sort partition(t) select si,i,b,f,t from over1k where t is null or t=27;
+
+set hive.enforce.bucketing=true;
+set hive.enforce.sorting=true;
+
+-- map-reduce jobs modified by hive.optimize.sort.dynamic.partition optimization
+explain insert into table over1k_part partition(ds="foo", t) select si,i,b,f,t from over1k where t is null or t=27;
+explain insert into table over1k_part_limit partition(ds="foo", t) select si,i,b,f,t from over1k where t is null or t=27 limit 10;
+explain insert into table over1k_part_buck partition(t) select si,i,b,f,t from over1k where t is null or t=27;
+explain insert into table over1k_part_buck_sort partition(t) select si,i,b,f,t from over1k where t is null or t=27;
+
+insert into table over1k_part partition(ds="foo", t) select si,i,b,f,t from over1k where t is null or t=27;
+insert into table over1k_part_limit partition(ds="foo", t) select si,i,b,f,t from over1k where t is null or t=27 limit 10;
+insert into table over1k_part_buck partition(t) select si,i,b,f,t from over1k where t is null or t=27;
+insert into table over1k_part_buck_sort partition(t) select si,i,b,f,t from over1k where t is null or t=27;
+
+desc formatted over1k_part partition(ds="foo",t=27);
+desc formatted over1k_part partition(ds="foo",t="__HIVE_DEFAULT_PARTITION__");
+desc formatted over1k_part_limit partition(ds="foo",t=27);
+desc formatted over1k_part_limit partition(ds="foo",t="__HIVE_DEFAULT_PARTITION__");
+desc formatted over1k_part_buck partition(t=27);
+desc formatted over1k_part_buck partition(t="__HIVE_DEFAULT_PARTITION__");
+desc formatted over1k_part_buck_sort partition(t=27);
+desc formatted over1k_part_buck_sort partition(t="__HIVE_DEFAULT_PARTITION__");
+
+select count(*) from over1k_part;
+select count(*) from over1k_part_limit;
+select count(*) from over1k_part_buck;
+select count(*) from over1k_part_buck_sort;
diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/FileSinkOperator.java ql/src/java/org/apache/hadoop/hive/ql/exec/FileSinkOperator.java
index 254b586..f627a25 100644
--- ql/src/java/org/apache/hadoop/hive/ql/exec/FileSinkOperator.java
+++ ql/src/java/org/apache/hadoop/hive/ql/exec/FileSinkOperator.java
@@ -33,25 +33,25 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hive.common.FileUtils;
import org.apache.hadoop.hive.common.StatsSetupConst;
+import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.ql.ErrorMsg;
import org.apache.hadoop.hive.ql.io.FSRecordWriter;
import org.apache.hadoop.hive.ql.io.FSRecordWriter.StatsProvidingRecordWriter;
-import org.apache.hadoop.hive.conf.HiveConf;
-import org.apache.hadoop.hive.ql.metadata.HiveFatalException;
import org.apache.hadoop.hive.ql.io.HiveFileFormatUtils;
import org.apache.hadoop.hive.ql.io.HiveKey;
import org.apache.hadoop.hive.ql.io.HiveOutputFormat;
import org.apache.hadoop.hive.ql.io.HivePartitioner;
import org.apache.hadoop.hive.ql.io.HivePassThroughOutputFormat;
import org.apache.hadoop.hive.ql.metadata.HiveException;
+import org.apache.hadoop.hive.ql.metadata.HiveFatalException;
import org.apache.hadoop.hive.ql.plan.DynamicPartitionCtx;
import org.apache.hadoop.hive.ql.plan.ExprNodeDesc;
import org.apache.hadoop.hive.ql.plan.FileSinkDesc;
+import org.apache.hadoop.hive.ql.plan.FileSinkDesc.DPSortState;
import org.apache.hadoop.hive.ql.plan.ListBucketingCtx;
import org.apache.hadoop.hive.ql.plan.PlanUtils;
import org.apache.hadoop.hive.ql.plan.SkewedColumnPositionPair;
import org.apache.hadoop.hive.ql.plan.api.OperatorType;
-import org.apache.hadoop.hive.ql.stats.CounterStatsPublisher;
import org.apache.hadoop.hive.ql.stats.StatsCollectionTaskIndependent;
import org.apache.hadoop.hive.ql.stats.StatsPublisher;
import org.apache.hadoop.hive.serde2.SerDeException;
@@ -68,6 +68,8 @@
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.util.ReflectionUtils;
+import com.google.common.collect.Lists;
+
/**
* File Sink operator implementation.
**/
@@ -93,6 +95,12 @@
protected transient boolean statsCollectRawDataSize;
private transient boolean[] statsFromRecordWriter;
private transient boolean isCollectRWStats;
+ private transient FSPaths prevFsp;
+ private transient FSPaths fpaths;
+ private transient ObjectInspector keyOI;
+ private transient List
+
+
+
true
diff --git ql/src/test/results/compiler/plan/cast1.q.xml ql/src/test/results/compiler/plan/cast1.q.xml
index 800a79a..ca4ad4c 100644
--- ql/src/test/results/compiler/plan/cast1.q.xml
+++ ql/src/test/results/compiler/plan/cast1.q.xml
@@ -176,6 +176,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
diff --git ql/src/test/results/compiler/plan/groupby1.q.xml ql/src/test/results/compiler/plan/groupby1.q.xml
index 75d8ccf..284f0a3 100755
--- ql/src/test/results/compiler/plan/groupby1.q.xml
+++ ql/src/test/results/compiler/plan/groupby1.q.xml
@@ -399,6 +399,9 @@
+
+ -1
+
1
@@ -1080,6 +1083,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
true
diff --git ql/src/test/results/compiler/plan/groupby2.q.xml ql/src/test/results/compiler/plan/groupby2.q.xml
index 13db49b..58623d9 100755
--- ql/src/test/results/compiler/plan/groupby2.q.xml
+++ ql/src/test/results/compiler/plan/groupby2.q.xml
@@ -294,6 +294,9 @@
+
+ -1
+
1
@@ -1195,6 +1198,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
diff --git ql/src/test/results/compiler/plan/groupby3.q.xml ql/src/test/results/compiler/plan/groupby3.q.xml
index 281244b..65b403b 100644
--- ql/src/test/results/compiler/plan/groupby3.q.xml
+++ ql/src/test/results/compiler/plan/groupby3.q.xml
@@ -346,6 +346,9 @@
+
+ -1
+
1
@@ -1416,6 +1419,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
diff --git ql/src/test/results/compiler/plan/groupby4.q.xml ql/src/test/results/compiler/plan/groupby4.q.xml
index 65350b1..cb1a99b 100644
--- ql/src/test/results/compiler/plan/groupby4.q.xml
+++ ql/src/test/results/compiler/plan/groupby4.q.xml
@@ -233,6 +233,9 @@
+
+ -1
+
1
@@ -817,6 +820,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
diff --git ql/src/test/results/compiler/plan/groupby5.q.xml ql/src/test/results/compiler/plan/groupby5.q.xml
index d169b74..2fb8f20 100644
--- ql/src/test/results/compiler/plan/groupby5.q.xml
+++ ql/src/test/results/compiler/plan/groupby5.q.xml
@@ -251,6 +251,9 @@
+
+ -1
+
1
@@ -923,6 +926,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
diff --git ql/src/test/results/compiler/plan/groupby6.q.xml ql/src/test/results/compiler/plan/groupby6.q.xml
index aae5342..c2d9a36 100644
--- ql/src/test/results/compiler/plan/groupby6.q.xml
+++ ql/src/test/results/compiler/plan/groupby6.q.xml
@@ -233,6 +233,9 @@
+
+ -1
+
1
@@ -817,6 +820,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
diff --git ql/src/test/results/compiler/plan/input1.q.xml ql/src/test/results/compiler/plan/input1.q.xml
index a5ede36..2cf7a1d 100755
--- ql/src/test/results/compiler/plan/input1.q.xml
+++ ql/src/test/results/compiler/plan/input1.q.xml
@@ -88,6 +88,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
@@ -729,6 +734,9 @@
#### A masked pattern was here ####
+
+
+
true
diff --git ql/src/test/results/compiler/plan/input2.q.xml ql/src/test/results/compiler/plan/input2.q.xml
index c0b62ba..87acdce 100755
--- ql/src/test/results/compiler/plan/input2.q.xml
+++ ql/src/test/results/compiler/plan/input2.q.xml
@@ -88,6 +88,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
@@ -634,6 +639,9 @@
#### A masked pattern was here ####
+
+
+
1
@@ -1117,6 +1125,9 @@
#### A masked pattern was here ####
+
+
+
1
@@ -1708,6 +1719,9 @@
#### A masked pattern was here ####
+
+
+
true
@@ -1975,6 +1989,9 @@
#### A masked pattern was here ####
+
+
+
true
@@ -2256,6 +2273,9 @@
#### A masked pattern was here ####
+
+
+
true
diff --git ql/src/test/results/compiler/plan/input20.q.xml ql/src/test/results/compiler/plan/input20.q.xml
index d40bcf3..f58eec2 100644
--- ql/src/test/results/compiler/plan/input20.q.xml
+++ ql/src/test/results/compiler/plan/input20.q.xml
@@ -248,6 +248,9 @@
+
+ -1
+
1
@@ -917,6 +920,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
diff --git ql/src/test/results/compiler/plan/input3.q.xml ql/src/test/results/compiler/plan/input3.q.xml
index 58d6234..bdeb25d 100755
--- ql/src/test/results/compiler/plan/input3.q.xml
+++ ql/src/test/results/compiler/plan/input3.q.xml
@@ -88,6 +88,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
@@ -634,6 +639,9 @@
#### A masked pattern was here ####
+
+
+
1
@@ -1176,6 +1184,9 @@
#### A masked pattern was here ####
+
+
+
1
@@ -1696,6 +1707,9 @@
#### A masked pattern was here ####
+
+
+
1
@@ -2166,6 +2180,9 @@
#### A masked pattern was here ####
+
+
+
true
@@ -2433,6 +2450,9 @@
#### A masked pattern was here ####
+
+
+
true
@@ -2714,6 +2734,9 @@
#### A masked pattern was here ####
+
+
+
true
@@ -2989,6 +3012,9 @@
#### A masked pattern was here ####
+
+
+
1
diff --git ql/src/test/results/compiler/plan/input4.q.xml ql/src/test/results/compiler/plan/input4.q.xml
index 2865043..b2cb682 100755
--- ql/src/test/results/compiler/plan/input4.q.xml
+++ ql/src/test/results/compiler/plan/input4.q.xml
@@ -399,6 +399,9 @@
+
+ -1
+
1
@@ -1077,6 +1080,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
true
diff --git ql/src/test/results/compiler/plan/input5.q.xml ql/src/test/results/compiler/plan/input5.q.xml
index 0725a28..5749e34 100644
--- ql/src/test/results/compiler/plan/input5.q.xml
+++ ql/src/test/results/compiler/plan/input5.q.xml
@@ -404,6 +404,9 @@
+
+ -1
+
1
@@ -1143,6 +1146,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
true
diff --git ql/src/test/results/compiler/plan/input6.q.xml ql/src/test/results/compiler/plan/input6.q.xml
index 7e1370a..a94ee15 100644
--- ql/src/test/results/compiler/plan/input6.q.xml
+++ ql/src/test/results/compiler/plan/input6.q.xml
@@ -88,6 +88,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
@@ -729,6 +734,9 @@
#### A masked pattern was here ####
+
+
+
true
diff --git ql/src/test/results/compiler/plan/input7.q.xml ql/src/test/results/compiler/plan/input7.q.xml
index c69de0b..80aac8d 100644
--- ql/src/test/results/compiler/plan/input7.q.xml
+++ ql/src/test/results/compiler/plan/input7.q.xml
@@ -88,6 +88,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
@@ -726,6 +731,9 @@
#### A masked pattern was here ####
+
+
+
true
diff --git ql/src/test/results/compiler/plan/input8.q.xml ql/src/test/results/compiler/plan/input8.q.xml
index 1c470fb..c79a8a3 100644
--- ql/src/test/results/compiler/plan/input8.q.xml
+++ ql/src/test/results/compiler/plan/input8.q.xml
@@ -173,6 +173,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
diff --git ql/src/test/results/compiler/plan/input9.q.xml ql/src/test/results/compiler/plan/input9.q.xml
index 5001196..7935d64 100644
--- ql/src/test/results/compiler/plan/input9.q.xml
+++ ql/src/test/results/compiler/plan/input9.q.xml
@@ -88,6 +88,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
@@ -729,6 +734,9 @@
#### A masked pattern was here ####
+
+
+
true
diff --git ql/src/test/results/compiler/plan/input_part1.q.xml ql/src/test/results/compiler/plan/input_part1.q.xml
index 621d565..49bfc66 100644
--- ql/src/test/results/compiler/plan/input_part1.q.xml
+++ ql/src/test/results/compiler/plan/input_part1.q.xml
@@ -197,6 +197,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
diff --git ql/src/test/results/compiler/plan/input_testsequencefile.q.xml ql/src/test/results/compiler/plan/input_testsequencefile.q.xml
index 2d06024..ca08c02 100644
--- ql/src/test/results/compiler/plan/input_testsequencefile.q.xml
+++ ql/src/test/results/compiler/plan/input_testsequencefile.q.xml
@@ -88,6 +88,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
@@ -667,6 +672,9 @@
#### A masked pattern was here ####
+
+
+
true
diff --git ql/src/test/results/compiler/plan/input_testxpath.q.xml ql/src/test/results/compiler/plan/input_testxpath.q.xml
index b2708c1..2ba0b5e 100644
--- ql/src/test/results/compiler/plan/input_testxpath.q.xml
+++ ql/src/test/results/compiler/plan/input_testxpath.q.xml
@@ -181,6 +181,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
diff --git ql/src/test/results/compiler/plan/input_testxpath2.q.xml ql/src/test/results/compiler/plan/input_testxpath2.q.xml
index bfb4fac..613752b 100644
--- ql/src/test/results/compiler/plan/input_testxpath2.q.xml
+++ ql/src/test/results/compiler/plan/input_testxpath2.q.xml
@@ -184,6 +184,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
diff --git ql/src/test/results/compiler/plan/join1.q.xml ql/src/test/results/compiler/plan/join1.q.xml
index 9abe035..217e0b7 100644
--- ql/src/test/results/compiler/plan/join1.q.xml
+++ ql/src/test/results/compiler/plan/join1.q.xml
@@ -464,6 +464,9 @@
+
+ -1
+
1
@@ -776,6 +779,9 @@
+
+ -1
+
1
@@ -1127,6 +1133,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
true
diff --git ql/src/test/results/compiler/plan/join2.q.xml ql/src/test/results/compiler/plan/join2.q.xml
index cb47ff4..169e780 100644
--- ql/src/test/results/compiler/plan/join2.q.xml
+++ ql/src/test/results/compiler/plan/join2.q.xml
@@ -427,6 +427,9 @@
+
+ -1
+
1
@@ -689,6 +692,9 @@
+
+ -1
+
1
@@ -1105,6 +1111,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
true
@@ -1756,6 +1767,9 @@
+
+ -1
+
1
@@ -2042,6 +2056,9 @@
+
+ -1
+
1
@@ -2381,6 +2398,9 @@
#### A masked pattern was here ####
+
+
+
1
diff --git ql/src/test/results/compiler/plan/join3.q.xml ql/src/test/results/compiler/plan/join3.q.xml
index d018a1e..ccea1e7 100644
--- ql/src/test/results/compiler/plan/join3.q.xml
+++ ql/src/test/results/compiler/plan/join3.q.xml
@@ -515,6 +515,9 @@
+
+ -1
+
1
@@ -811,6 +814,9 @@
+
+ -1
+
1
@@ -1119,6 +1125,9 @@
+
+ -1
+
1
@@ -1473,6 +1482,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
true
diff --git ql/src/test/results/compiler/plan/join4.q.xml ql/src/test/results/compiler/plan/join4.q.xml
index 6ae29e9..54504cd 100644
--- ql/src/test/results/compiler/plan/join4.q.xml
+++ ql/src/test/results/compiler/plan/join4.q.xml
@@ -313,6 +313,9 @@
+
+ -1
+
1
@@ -865,6 +868,9 @@
+
+ -1
+
1
@@ -1456,6 +1462,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
diff --git ql/src/test/results/compiler/plan/join5.q.xml ql/src/test/results/compiler/plan/join5.q.xml
index 35cfabb..76ac5f3 100644
--- ql/src/test/results/compiler/plan/join5.q.xml
+++ ql/src/test/results/compiler/plan/join5.q.xml
@@ -313,6 +313,9 @@
+
+ -1
+
1
@@ -865,6 +868,9 @@
+
+ -1
+
1
@@ -1456,6 +1462,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
diff --git ql/src/test/results/compiler/plan/join6.q.xml ql/src/test/results/compiler/plan/join6.q.xml
index 045b4cb..b1e6c17 100644
--- ql/src/test/results/compiler/plan/join6.q.xml
+++ ql/src/test/results/compiler/plan/join6.q.xml
@@ -313,6 +313,9 @@
+
+ -1
+
1
@@ -865,6 +868,9 @@
+
+ -1
+
1
@@ -1456,6 +1462,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
diff --git ql/src/test/results/compiler/plan/join7.q.xml ql/src/test/results/compiler/plan/join7.q.xml
index c76764d..120adc2 100644
--- ql/src/test/results/compiler/plan/join7.q.xml
+++ ql/src/test/results/compiler/plan/join7.q.xml
@@ -378,6 +378,9 @@
+
+ -1
+
1
@@ -930,6 +933,9 @@
+
+ -1
+
1
@@ -1473,6 +1479,9 @@
+
+ -1
+
1
@@ -2067,6 +2076,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
diff --git ql/src/test/results/compiler/plan/join8.q.xml ql/src/test/results/compiler/plan/join8.q.xml
index 3b960d7..468beb1 100644
--- ql/src/test/results/compiler/plan/join8.q.xml
+++ ql/src/test/results/compiler/plan/join8.q.xml
@@ -313,6 +313,9 @@
+
+ -1
+
1
@@ -906,6 +909,9 @@
+
+ -1
+
1
@@ -1541,6 +1547,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
diff --git ql/src/test/results/compiler/plan/sample1.q.xml ql/src/test/results/compiler/plan/sample1.q.xml
index 6d878f2..1602b70 100644
--- ql/src/test/results/compiler/plan/sample1.q.xml
+++ ql/src/test/results/compiler/plan/sample1.q.xml
@@ -197,6 +197,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
diff --git ql/src/test/results/compiler/plan/sample2.q.xml ql/src/test/results/compiler/plan/sample2.q.xml
index 660827c..d299859 100644
--- ql/src/test/results/compiler/plan/sample2.q.xml
+++ ql/src/test/results/compiler/plan/sample2.q.xml
@@ -88,6 +88,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
@@ -737,6 +742,9 @@
#### A masked pattern was here ####
+
+
+
true
diff --git ql/src/test/results/compiler/plan/sample3.q.xml ql/src/test/results/compiler/plan/sample3.q.xml
index 6b8b458..37c3fbb 100644
--- ql/src/test/results/compiler/plan/sample3.q.xml
+++ ql/src/test/results/compiler/plan/sample3.q.xml
@@ -88,6 +88,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
@@ -737,6 +742,9 @@
#### A masked pattern was here ####
+
+
+
true
diff --git ql/src/test/results/compiler/plan/sample4.q.xml ql/src/test/results/compiler/plan/sample4.q.xml
index 660827c..d299859 100644
--- ql/src/test/results/compiler/plan/sample4.q.xml
+++ ql/src/test/results/compiler/plan/sample4.q.xml
@@ -88,6 +88,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
@@ -737,6 +742,9 @@
#### A masked pattern was here ####
+
+
+
true
diff --git ql/src/test/results/compiler/plan/sample5.q.xml ql/src/test/results/compiler/plan/sample5.q.xml
index 3ca2e3a..cc2275b 100644
--- ql/src/test/results/compiler/plan/sample5.q.xml
+++ ql/src/test/results/compiler/plan/sample5.q.xml
@@ -88,6 +88,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
@@ -737,6 +742,9 @@
#### A masked pattern was here ####
+
+
+
true
diff --git ql/src/test/results/compiler/plan/sample6.q.xml ql/src/test/results/compiler/plan/sample6.q.xml
index 4305409..93315d8 100644
--- ql/src/test/results/compiler/plan/sample6.q.xml
+++ ql/src/test/results/compiler/plan/sample6.q.xml
@@ -88,6 +88,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
@@ -737,6 +742,9 @@
#### A masked pattern was here ####
+
+
+
true
diff --git ql/src/test/results/compiler/plan/sample7.q.xml ql/src/test/results/compiler/plan/sample7.q.xml
index 96e5d3f..bd05d53 100644
--- ql/src/test/results/compiler/plan/sample7.q.xml
+++ ql/src/test/results/compiler/plan/sample7.q.xml
@@ -88,6 +88,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
@@ -737,6 +742,9 @@
#### A masked pattern was here ####
+
+
+
true
diff --git ql/src/test/results/compiler/plan/subq.q.xml ql/src/test/results/compiler/plan/subq.q.xml
index 60863d2..ad63615 100644
--- ql/src/test/results/compiler/plan/subq.q.xml
+++ ql/src/test/results/compiler/plan/subq.q.xml
@@ -53,6 +53,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
@@ -549,6 +554,9 @@
#### A masked pattern was here ####
+
+
+
1
diff --git ql/src/test/results/compiler/plan/udf1.q.xml ql/src/test/results/compiler/plan/udf1.q.xml
index 196bff1..3e944ad 100644
--- ql/src/test/results/compiler/plan/udf1.q.xml
+++ ql/src/test/results/compiler/plan/udf1.q.xml
@@ -176,6 +176,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
diff --git ql/src/test/results/compiler/plan/udf4.q.xml ql/src/test/results/compiler/plan/udf4.q.xml
index fdf3f31..a5b13e4 100644
--- ql/src/test/results/compiler/plan/udf4.q.xml
+++ ql/src/test/results/compiler/plan/udf4.q.xml
@@ -153,6 +153,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
diff --git ql/src/test/results/compiler/plan/udf6.q.xml ql/src/test/results/compiler/plan/udf6.q.xml
index 8285077..c04aaba 100644
--- ql/src/test/results/compiler/plan/udf6.q.xml
+++ ql/src/test/results/compiler/plan/udf6.q.xml
@@ -173,6 +173,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
diff --git ql/src/test/results/compiler/plan/udf_case.q.xml ql/src/test/results/compiler/plan/udf_case.q.xml
index 55b9e2d..40fe450 100644
--- ql/src/test/results/compiler/plan/udf_case.q.xml
+++ ql/src/test/results/compiler/plan/udf_case.q.xml
@@ -176,6 +176,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
diff --git ql/src/test/results/compiler/plan/udf_when.q.xml ql/src/test/results/compiler/plan/udf_when.q.xml
index 626431f..6b73dbd 100644
--- ql/src/test/results/compiler/plan/udf_when.q.xml
+++ ql/src/test/results/compiler/plan/udf_when.q.xml
@@ -176,6 +176,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
diff --git ql/src/test/results/compiler/plan/union.q.xml ql/src/test/results/compiler/plan/union.q.xml
index 3945da6..34224e0 100644
--- ql/src/test/results/compiler/plan/union.q.xml
+++ ql/src/test/results/compiler/plan/union.q.xml
@@ -53,6 +53,11 @@
#### A masked pattern was here ####
+
+
+ NONE
+
+
1
@@ -620,6 +625,9 @@
#### A masked pattern was here ####
+
+
+
1