This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.0 by this push:
new 6db95cf9992 branch-4.0: [fix](fe) Fix Type.exceedsMaxNestingDepth
skipping MAP keyType recursion #63201 (#63212)
6db95cf9992 is described below
commit 6db95cf999231d15591801f83ba27969d6bb85a4
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri May 15 21:09:55 2026 -0700
branch-4.0: [fix](fe) Fix Type.exceedsMaxNestingDepth skipping MAP keyType
recursion #63201 (#63212)
Cherry-picked from #63201
Co-authored-by: morrySnow <[email protected]>
Co-authored-by: Copilot <[email protected]>
---
.../main/java/org/apache/doris/catalog/Type.java | 3 ++
.../java/org/apache/doris/catalog/TypeTest.java | 40 ++++++++++++++++++++++
2 files changed, 43 insertions(+)
diff --git a/fe/fe-common/src/main/java/org/apache/doris/catalog/Type.java
b/fe/fe-common/src/main/java/org/apache/doris/catalog/Type.java
index 3cd318aa6c5..d9d2a13e366 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/catalog/Type.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/catalog/Type.java
@@ -797,6 +797,9 @@ public abstract class Type {
return itemType.exceedsMaxNestingDepth(d + 1);
} else if (isMapType()) {
MapType mapType = (MapType) this;
+ if (mapType.getKeyType().exceedsMaxNestingDepth(d + 1)) {
+ return true;
+ }
return mapType.getValueType().exceedsMaxNestingDepth(d + 1);
} else {
Preconditions.checkState(isScalarType() || isAggStateType());
diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/TypeTest.java
b/fe/fe-core/src/test/java/org/apache/doris/catalog/TypeTest.java
index fe3e2b0bd0a..213ad88db0e 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/catalog/TypeTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/TypeTest.java
@@ -177,6 +177,46 @@ public class TypeTest {
Assert.assertFalse(Type.matchExactType(d20s1, d38s1, false));
}
+ // ===================== exceedsMaxNestingDepth =====================
+
+ /**
+ * Builds a MAP<MAP<...<MAP<STRING, STRING>>...>, STRING> with the given
number of outer MAP wrappers.
+ * This tests the keyType recursion path of exceedsMaxNestingDepth().
+ */
+ private static Type buildMapKeyNestedType(int depth) {
+ // innermost: MAP<STRING, STRING> counts as depth 1 (from the caller's
perspective we start at d=0)
+ Type current = new MapType(Type.STRING, Type.STRING, true, true);
+ for (int i = 1; i < depth; i++) {
+ current = new MapType(current, Type.STRING, true, true);
+ }
+ return current;
+ }
+
+ @Test
+ public void testMapKeyPathNestingWithinLimit() {
+ // MAP < MAP < ... STRING ...>, STRING > with total nesting ==
MAX_NESTING_DEPTH should be allowed
+ Type t = buildMapKeyNestedType(Type.MAX_NESTING_DEPTH);
+ Assert.assertFalse(t.exceedsMaxNestingDepth());
+ }
+
+ @Test
+ public void testMapKeyPathDeepNestingDetected() {
+ // Nesting depth of MAX_NESTING_DEPTH + 1 via keyType path must be
rejected
+ Type t = buildMapKeyNestedType(Type.MAX_NESTING_DEPTH + 1);
+ Assert.assertTrue(t.exceedsMaxNestingDepth());
+ }
+
+ @Test
+ public void testMapValuePathDeepNestingDetected() {
+ // Existing valueType path should still be detected (regression guard).
+ // Need MAX_NESTING_DEPTH + 1 wraps so the innermost reaches d =
MAX_NESTING_DEPTH + 1.
+ Type current = Type.STRING;
+ for (int i = 0; i <= Type.MAX_NESTING_DEPTH; i++) {
+ current = new MapType(Type.STRING, current, true, true);
+ }
+ Assert.assertTrue(current.exceedsMaxNestingDepth());
+ }
+
@Test
public void testDatetimeV2ScaleMatching() {
ScalarType dtv2s3 = ScalarType.createDatetimeV2Type(3);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]