Skip to content

branch-4.0: [fix](fe) Fix Type.exceedsMaxNestingDepth skipping MAP keyType recursion #63201#63212

Merged
morningman merged 1 commit into
branch-4.0from
auto-pick-63201-branch-4.0
May 16, 2026
Merged

branch-4.0: [fix](fe) Fix Type.exceedsMaxNestingDepth skipping MAP keyType recursion #63201#63212
morningman merged 1 commit into
branch-4.0from
auto-pick-63201-branch-4.0

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Cherry-picked from #63201

…ion (#63201)

## Summary

`Type.exceedsMaxNestingDepth` in the MAP branch only recursed into
`valueType` and silently skipped `keyType`. A user could construct
arbitrarily deep types via the MAP key path, bypassing the 9-layer
nesting limit.

### What problem does this PR solve?

Problem Summary:

```java
// Before fix — MAP branch:
} else if (isMapType()) {
    MapType mapType = (MapType) this;
    return mapType.getValueType().exceedsMaxNestingDepth(d + 1);  // keyType never checked
}
```

ARRAY and STRUCT branches recursed correctly; only MAP missed the
keyType path.

### Fix

```java
} else if (isMapType()) {
    MapType mapType = (MapType) this;
    if (mapType.getKeyType().exceedsMaxNestingDepth(d + 1)) {
        return true;
    }
    return mapType.getValueType().exceedsMaxNestingDepth(d + 1);
}
```

### Tests

Three new FE unit tests added to `TypeTest`:

- `testMapKeyPathNestingWithinLimit` — `MAX_NESTING_DEPTH` levels via
keyType → allowed (assertFalse)
- `testMapKeyPathDeepNestingDetected` — `MAX_NESTING_DEPTH + 1` levels
via keyType → rejected (assertTrue)
- `testMapValuePathDeepNestingDetected` — regression guard: valueType
path still detected (assertTrue)

All 11 tests in `TypeTest` pass.

### Release note

Fix MAP key-type nesting-depth check bypass: deeply-nested MAP key types
are now correctly rejected with "Type exceeds the maximum nesting
depth".

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@hello-stephen
Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@hello-stephen
Copy link
Copy Markdown
Contributor

run buildall

@morningman morningman merged commit 6db95cf into branch-4.0 May 16, 2026
28 of 32 checks passed
@github-actions github-actions Bot deleted the auto-pick-63201-branch-4.0 branch May 16, 2026 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants