This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.1 by this push:
new 7933d63dd47 branch-4.1: [fix](fe) Parse MaxCompute partition specs by
name #64937 (#65227)
7933d63dd47 is described below
commit 7933d63dd47a92ad10972c98907958afb0bf2903
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Jul 7 13:44:46 2026 +0800
branch-4.1: [fix](fe) Parse MaxCompute partition specs by name #64937
(#65227)
Cherry-picked from #64937
Co-authored-by: daidai <[email protected]>
---
.../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 839995ca5f6..85e592b6f3d 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
@@ -134,18 +134,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]