This is an automated email from the ASF dual-hosted git repository.
Gabriel39 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 9561ad9e8c9 [fix](fe) Parse MaxCompute partition specs by name (#64937)
9561ad9e8c9 is described below
commit 9561ad9e8c9e168339df310b78df49e8bdde21a4
Author: daidai <[email protected]>
AuthorDate: Mon Jul 6 11:10:28 2026 +0800
[fix](fe) Parse MaxCompute partition specs by name (#64937)
MaxCompute partition specs were parsed by fragment
position and silently accepted fragments whose column prefix did not
match the expected partition column. If a partition spec is not ordered
the same way as the table partition columns, Doris can bind values to
the wrong partition columns during internal partition pruning. This
change parses each fragment as name=value, rejects malformed, duplicate,
or unexpected partition columns, and returns values ordered by the table
partition column list.
---
.../maxcompute/MaxComputeExternalTable.java | 35 +++++++++++----
.../maxcompute/MaxComputeExternalTableTest.java | 50 ++++++++++++++++++++++
2 files changed, 77 insertions(+), 8 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/maxcompute/MaxComputeExternalTable.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/maxcompute/MaxComputeExternalTable.java
index ec6e7f79d6d..1ca1e42b0c7 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/maxcompute/MaxComputeExternalTable.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/maxcompute/MaxComputeExternalTable.java
@@ -135,18 +135,37 @@ public class MaxComputeExternalTable extends
ExternalTable {
* @return all values of partitionPath
*/
static List<String> parsePartitionValues(List<String> partitionColumns,
String partitionPath) {
- String[] partitionFragments = partitionPath.split("/");
+ String[] partitionFragments = partitionPath.split("/", -1);
if (partitionFragments.length != partitionColumns.size()) {
throw new RuntimeException("Failed to parse partition values of
path: " + partitionPath);
}
- List<String> partitionValues = new
ArrayList<>(partitionFragments.length);
- for (int i = 0; i < partitionFragments.length; i++) {
- String prefix = partitionColumns.get(i) + "=";
- if (partitionFragments[i].startsWith(prefix)) {
-
partitionValues.add(partitionFragments[i].substring(prefix.length()));
- } else {
- partitionValues.add(partitionFragments[i]);
+ Map<String, String> partitionNameToValue =
Maps.newHashMapWithExpectedSize(partitionFragments.length);
+ for (String partitionFragment : partitionFragments) {
+ int separatorIndex = partitionFragment.indexOf('=');
+ if (separatorIndex <= 0) {
+ throw new RuntimeException("Failed to parse partition values
of path: " + partitionPath);
}
+
+ String partitionName = partitionFragment.substring(0,
separatorIndex);
+ if (!partitionColumns.contains(partitionName)) {
+ throw new RuntimeException("Unexpected partition column " +
partitionName + " in path: "
+ + partitionPath);
+ }
+
+ String partitionValue = partitionFragment.substring(separatorIndex
+ 1);
+ if (partitionNameToValue.put(partitionName, partitionValue) !=
null) {
+ throw new RuntimeException("Duplicate partition column " +
partitionName + " in path: "
+ + partitionPath);
+ }
+ }
+
+ List<String> partitionValues = new
ArrayList<>(partitionColumns.size());
+ for (String partitionColumn : partitionColumns) {
+ if (!partitionNameToValue.containsKey(partitionColumn)) {
+ throw new RuntimeException("Missing partition column " +
partitionColumn + " in path: "
+ + partitionPath);
+ }
+ partitionValues.add(partitionNameToValue.get(partitionColumn));
}
return partitionValues;
}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/datasource/maxcompute/MaxComputeExternalTableTest.java
b/fe/fe-core/src/test/java/org/apache/doris/datasource/maxcompute/MaxComputeExternalTableTest.java
new file mode 100644
index 00000000000..abbb4d3394f
--- /dev/null
+++
b/fe/fe-core/src/test/java/org/apache/doris/datasource/maxcompute/MaxComputeExternalTableTest.java
@@ -0,0 +1,50 @@
+// 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.
+
+package org.apache.doris.datasource.maxcompute;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class MaxComputeExternalTableTest {
+ @Test
+ public void testParsePartitionValues() {
+ List<String> partitionColumns = Arrays.asList("p1", "p2");
+
+ Assert.assertEquals(Arrays.asList("a", "b"),
+ MaxComputeExternalTable.parsePartitionValues(partitionColumns,
"p1=a/p2=b"));
+ Assert.assertEquals(Arrays.asList("a", "b"),
+ MaxComputeExternalTable.parsePartitionValues(partitionColumns,
"p2=b/p1=a"));
+ }
+
+ @Test
+ public void testParsePartitionValuesRejectsInvalidSpec() {
+ List<String> partitionColumns = Arrays.asList("p1", "p2");
+
+ Assert.assertThrows(RuntimeException.class,
+ () ->
MaxComputeExternalTable.parsePartitionValues(partitionColumns, "p1=a"));
+ Assert.assertThrows(RuntimeException.class,
+ () ->
MaxComputeExternalTable.parsePartitionValues(partitionColumns, "p1=a/raw"));
+ Assert.assertThrows(RuntimeException.class,
+ () ->
MaxComputeExternalTable.parsePartitionValues(partitionColumns, "p1=a/p1=b"));
+ Assert.assertThrows(RuntimeException.class,
+ () ->
MaxComputeExternalTable.parsePartitionValues(partitionColumns, "p1=a/p3=b"));
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]