[fix](mtmv)fix generate partition name illegality when partition value contains colon (#31282)
This commit is contained in:
@ -45,9 +45,13 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class MTMVPartitionUtil {
|
||||
private static final Logger LOG = LogManager.getLogger(MTMVPartitionUtil.class);
|
||||
private static final Pattern PARTITION_NAME_PATTERN = Pattern.compile("[^a-zA-Z0-9,]");
|
||||
private static final String PARTITION_NAME_PREFIX = "p_";
|
||||
|
||||
/**
|
||||
* Determine whether the partition is sync with retated partition and other baseTables
|
||||
@ -286,9 +290,8 @@ public class MTMVPartitionUtil {
|
||||
* @return
|
||||
*/
|
||||
public static String generatePartitionName(PartitionKeyDesc desc) {
|
||||
String partitionName = "p_";
|
||||
partitionName += desc.toSql().trim().replaceAll("\\(|\\)|\\-|\\[|\\]|'|\\s+", "")
|
||||
.replaceAll("\\(|\\)|\\,|\\[|\\]", "_");
|
||||
Matcher matcher = PARTITION_NAME_PATTERN.matcher(desc.toSql());
|
||||
String partitionName = PARTITION_NAME_PREFIX + matcher.replaceAll("").replaceAll("\\,", "_");
|
||||
if (partitionName.length() > 50) {
|
||||
partitionName = partitionName.substring(0, 30) + Math.abs(Objects.hash(partitionName))
|
||||
+ "_" + System.currentTimeMillis();
|
||||
|
||||
Reference in New Issue
Block a user