mrhhsg opened a new pull request, #68114:
URL: https://github.com/apache/doris/pull/68114
### What problem does this PR solve?
Issue Number: None
Problem Summary:
When constant folding is skipped (`debug_skip_fold_constant = true`),
`element_at(NULL, 1)` is not folded on the FE and reaches the BE with the
container typed as a null literal (`TYPE_NULL`, mocked as `UInt8` in the BE).
`element_at` opts out of the default null handling, so its return type
resolution treated the mock type as a real `BOOL` container and failed with:
```
[INVALID_ARGUMENT][E33] element_at only support array and map so far, but
got BOOL
```
In debug builds the preceding `DCHECK` fires before that error is raised.
This change makes `element_at` recognize a null-literal container the same
way the default null implementation does: the return type resolves to
`Nullable(Nothing)` and execution produces a NULL for every row, which matches
the folded result.
```sql
SET debug_skip_fold_constant = true;
SELECT element_at(NULL, 1); -- NULL (previously: error "got BOOL")
SELECT element_at(NULL, 'k'); -- NULL
```
### Release note
None
### Check List (For Author)
- Test:
- Unit Test:
`function_array_element_test.element_at_null_literal_container`
- Regression test:
`query_p0/sql_functions/array_functions/test_element_at_null_container`
- Behavior changed: No
- Does this need documentation: No
### Check List (For Reviewer who merge this PR)
- Confirm the release note
- Confirm test cases
- Confirm document
- Add branch pick label
https://claude.ai/code/session_01HXcF45DSFT6fMDvtdNz2w8
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]