diff --git data/files/ext_test_space/folder+with space/data.txt data/files/ext_test_space/folder+with space/data.txt new file mode 100644 index 0000000..6a39069 --- /dev/null +++ data/files/ext_test_space/folder+with space/data.txt @@ -0,0 +1,3 @@ +12 jason +13 steven +15 joe \ No newline at end of file diff --git itests/qtest/pom.xml itests/qtest/pom.xml index 119ddb5..186a08b 100644 --- itests/qtest/pom.xml +++ itests/qtest/pom.xml @@ -36,7 +36,7 @@ false false - 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 + 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 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 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 ql/src/java/org/apache/hadoop/hive/ql/metadata/Partition.java ql/src/java/org/apache/hadoop/hive/ql/metadata/Partition.java index 0fe260d..0773b65 100644 --- ql/src/java/org/apache/hadoop/hive/ql/metadata/Partition.java +++ ql/src/java/org/apache/hadoop/hive/ql/metadata/Partition.java @@ -20,6 +20,7 @@ import java.io.Serializable; import java.net.URI; +import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -235,7 +236,12 @@ public Path getPartitionPath() { if (table.isPartitioned()) { return new Path(tPartition.getSd().getLocation()); } else { - return new Path(table.getTTable().getSd().getLocation()); + try { + return new Path(new URI(table.getTTable().getSd().getLocation())); + } catch (URISyntaxException e) { + LOG.info("Failed to construct Path from table location because: " + e.getMessage()); + return null; + } } } diff --git ql/src/java/org/apache/hadoop/hive/ql/metadata/Table.java ql/src/java/org/apache/hadoop/hive/ql/metadata/Table.java index 877d342..e992d0c 100644 --- ql/src/java/org/apache/hadoop/hive/ql/metadata/Table.java +++ ql/src/java/org/apache/hadoop/hive/ql/metadata/Table.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.io.Serializable; import java.net.URI; +import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -244,7 +245,11 @@ final public Path getPath() { if (location == null) { return null; } - return new Path(location); + try { + return new Path(new URI(location)); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } } final public String getTableName() { diff --git ql/src/test/queries/clientpositive/external_table_with_space_in_location_path.q ql/src/test/queries/clientpositive/external_table_with_space_in_location_path.q new file mode 100644 index 0000000..ad07046 --- /dev/null +++ ql/src/test/queries/clientpositive/external_table_with_space_in_location_path.q @@ -0,0 +1,23 @@ +dfs ${system:test.dfs.mkdir} hdfs:///tmp/test/; + +dfs -copyFromLocal ../../data/files/ext_test_space hdfs:///tmp/test/ext_test_space; + +CREATE EXTERNAL TABLE spacetest (id int, message string) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LOCATION 'hdfs:///tmp/test/ext_test_space/folder+with space'; + +SELECT * FROM spacetest; + +SELECT count(*) FROM spacetest; + +DROP TABLE spacetest; + +CREATE EXTERNAL TABLE spacetestpartition (id int, message string) PARTITIONED BY (day int) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'; + +ALTER TABLE spacetestpartition ADD PARTITION (day=10) LOCATION 'hdfs:///tmp/test/ext_test_space/folder+with space'; + +SELECT * FROM spacetestpartition; + +SELECT count(*) FROM spacetestpartition; + +DROP TABLE spacetestpartition; + +dfs -rmr hdfs:///tmp/test; diff --git ql/src/test/results/clientpositive/external_table_with_space_in_location_path.q.out ql/src/test/results/clientpositive/external_table_with_space_in_location_path.q.out new file mode 100644 index 0000000..2b12276 --- /dev/null +++ ql/src/test/results/clientpositive/external_table_with_space_in_location_path.q.out @@ -0,0 +1,78 @@ +#### A masked pattern was here #### +PREHOOK: type: CREATETABLE +#### A masked pattern was here #### +POSTHOOK: type: CREATETABLE +POSTHOOK: Output: default@spacetest +PREHOOK: query: SELECT * FROM spacetest +PREHOOK: type: QUERY +PREHOOK: Input: default@spacetest +#### A masked pattern was here #### +POSTHOOK: query: SELECT * FROM spacetest +POSTHOOK: type: QUERY +POSTHOOK: Input: default@spacetest +#### A masked pattern was here #### +12 jason +13 steven +15 joe +PREHOOK: query: SELECT count(*) FROM spacetest +PREHOOK: type: QUERY +PREHOOK: Input: default@spacetest +#### A masked pattern was here #### +POSTHOOK: query: SELECT count(*) FROM spacetest +POSTHOOK: type: QUERY +POSTHOOK: Input: default@spacetest +#### A masked pattern was here #### +3 +PREHOOK: query: DROP TABLE spacetest +PREHOOK: type: DROPTABLE +PREHOOK: Input: default@spacetest +PREHOOK: Output: default@spacetest +POSTHOOK: query: DROP TABLE spacetest +POSTHOOK: type: DROPTABLE +POSTHOOK: Input: default@spacetest +POSTHOOK: Output: default@spacetest +PREHOOK: query: CREATE EXTERNAL TABLE spacetestpartition (id int, message string) PARTITIONED BY (day int) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' +PREHOOK: type: CREATETABLE +POSTHOOK: query: CREATE EXTERNAL TABLE spacetestpartition (id int, message string) PARTITIONED BY (day int) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' +POSTHOOK: type: CREATETABLE +POSTHOOK: Output: default@spacetestpartition +#### A masked pattern was here #### +PREHOOK: type: ALTERTABLE_ADDPARTS +PREHOOK: Input: default@spacetestpartition +#### A masked pattern was here #### +POSTHOOK: type: ALTERTABLE_ADDPARTS +POSTHOOK: Input: default@spacetestpartition +POSTHOOK: Output: default@spacetestpartition@day=10 +PREHOOK: query: SELECT * FROM spacetestpartition +PREHOOK: type: QUERY +PREHOOK: Input: default@spacetestpartition +PREHOOK: Input: default@spacetestpartition@day=10 +#### A masked pattern was here #### +POSTHOOK: query: SELECT * FROM spacetestpartition +POSTHOOK: type: QUERY +POSTHOOK: Input: default@spacetestpartition +POSTHOOK: Input: default@spacetestpartition@day=10 +#### A masked pattern was here #### +12 jason 10 +13 steven 10 +15 joe 10 +PREHOOK: query: SELECT count(*) FROM spacetestpartition +PREHOOK: type: QUERY +PREHOOK: Input: default@spacetestpartition +PREHOOK: Input: default@spacetestpartition@day=10 +#### A masked pattern was here #### +POSTHOOK: query: SELECT count(*) FROM spacetestpartition +POSTHOOK: type: QUERY +POSTHOOK: Input: default@spacetestpartition +POSTHOOK: Input: default@spacetestpartition@day=10 +#### A masked pattern was here #### +3 +PREHOOK: query: DROP TABLE spacetestpartition +PREHOOK: type: DROPTABLE +PREHOOK: Input: default@spacetestpartition +PREHOOK: Output: default@spacetestpartition +POSTHOOK: query: DROP TABLE spacetestpartition +POSTHOOK: type: DROPTABLE +POSTHOOK: Input: default@spacetestpartition +POSTHOOK: Output: default@spacetestpartition +#### A masked pattern was here ####