[Fix](multi catalog)Fix hive partition value contains special character such as / bug (#21876)
Hive escapes some special characters in partition value to %XX, for example, / is escaped to %2F. Doris didn't handle this case which will cause doris failed to list the files under partition with special characters. This pr is to fix this bug.
This commit is contained in:
@ -74,6 +74,7 @@ import org.apache.hadoop.hdfs.HdfsConfiguration;
|
||||
import org.apache.hadoop.hive.common.ValidWriteIdList;
|
||||
import org.apache.hadoop.hive.metastore.api.Partition;
|
||||
import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
|
||||
import org.apache.hadoop.hive.metastore.utils.FileUtils;
|
||||
import org.apache.hadoop.hive.ql.io.AcidUtils;
|
||||
import org.apache.hadoop.mapred.FileInputFormat;
|
||||
import org.apache.hadoop.mapred.InputFormat;
|
||||
@ -339,7 +340,8 @@ public class HiveMetaStoreCache {
|
||||
for (int i = 0; i < partitionColumns.size(); i++) {
|
||||
sb.append(partitionColumns.get(i).getName());
|
||||
sb.append("=");
|
||||
sb.append(key.getValues().get(i));
|
||||
// Partition value may contain special character, like / and so on. Need to encode.
|
||||
sb.append(FileUtils.escapePathName(key.getValues().get(i)));
|
||||
sb.append("/");
|
||||
}
|
||||
sb.delete(sb.length() - 1, sb.length());
|
||||
|
||||
@ -0,0 +1,51 @@
|
||||
-- This file is automatically generated. You should know what you did if you want to edit this
|
||||
-- !1 --
|
||||
name# 2023#01#01
|
||||
name1 2023/01/01
|
||||
name10 2023<01><01>
|
||||
name11 2023\\01\\01
|
||||
name12 2023.01.01
|
||||
name2 2023 01 01
|
||||
name3 2023:01:01
|
||||
name4 2023?01?01
|
||||
name5 2023=01=01
|
||||
name6 2023%01%01
|
||||
name8 2023"01"01
|
||||
name9 2023'01'01
|
||||
|
||||
-- !2 --
|
||||
name2
|
||||
|
||||
-- !3 --
|
||||
name1
|
||||
|
||||
-- !4 --
|
||||
name4 2023?01?01
|
||||
|
||||
-- !5 --
|
||||
name12 2023.01.01
|
||||
|
||||
-- !6 --
|
||||
name10 2023<01><01>
|
||||
|
||||
-- !7 --
|
||||
name3 2023:01:01
|
||||
|
||||
-- !8 --
|
||||
name5 2023=01=01
|
||||
|
||||
-- !9 --
|
||||
name8 2023"01"01
|
||||
|
||||
-- !10 --
|
||||
name9 2023'01'01
|
||||
|
||||
-- !11 --
|
||||
name11 2023\\01\\01
|
||||
|
||||
-- !12 --
|
||||
name6 2023%01%01
|
||||
|
||||
-- !13 --
|
||||
name# 2023#01#01
|
||||
|
||||
@ -0,0 +1,51 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
suite("test_hive_special_char_partition", "p2") {
|
||||
String enabled = context.config.otherConfigs.get("enableExternalHiveTest")
|
||||
if (enabled != null && enabled.equalsIgnoreCase("true")) {
|
||||
String extHiveHmsHost = context.config.otherConfigs.get("extHiveHmsHost")
|
||||
String extHiveHmsPort = context.config.otherConfigs.get("extHiveHmsPort")
|
||||
String catalog_name = "test_hive_special_char_partition"
|
||||
sql """drop catalog if exists ${catalog_name};"""
|
||||
sql """
|
||||
create catalog if not exists ${catalog_name} properties (
|
||||
'type'='hms',
|
||||
'hadoop.username' = 'hadoop',
|
||||
'hive.metastore.uris' = 'thrift://${extHiveHmsHost}:${extHiveHmsPort}'
|
||||
);
|
||||
"""
|
||||
logger.info("catalog " + catalog_name + " created")
|
||||
sql """switch ${catalog_name};"""
|
||||
logger.info("switched to catalog " + catalog_name)
|
||||
sql """use multi_catalog;"""
|
||||
qt_1 "select * from special_character_1_partition order by name"
|
||||
qt_2 "select name from special_character_1_partition where part='2023 01 01'"
|
||||
qt_3 "select name from special_character_1_partition where part='2023/01/01'"
|
||||
qt_4 "select * from special_character_1_partition where part='2023?01?01'"
|
||||
qt_5 "select * from special_character_1_partition where part='2023.01.01'"
|
||||
qt_6 "select * from special_character_1_partition where part='2023<01><01>'"
|
||||
qt_7 "select * from special_character_1_partition where part='2023:01:01'"
|
||||
qt_8 "select * from special_character_1_partition where part='2023=01=01'"
|
||||
qt_9 "select * from special_character_1_partition where part='2023\"01\"01'"
|
||||
qt_10 "select * from special_character_1_partition where part='2023\\'01\\'01'"
|
||||
qt_11 "select * from special_character_1_partition where part='2023\\\\01\\\\01'"
|
||||
qt_12 "select * from special_character_1_partition where part='2023%01%01'"
|
||||
qt_13 "select * from special_character_1_partition where part='2023#01#01'"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user