morrySnow opened a new pull request, #67887:
URL: https://github.com/apache/doris/pull/67887
## Problem
An outer join can make one input of `struct` or `named_struct` nullable
after the function has already been bound. When the struct is evaluated in a
join condition, FE can still send a non-nullable nested field type while BE
produces a nullable column. The mismatch reaches
`ColumnStruct::insert_range_from` and can terminate the BE instead of returning
the correct outer-join rows.
## Root cause
Nullability rewrites intentionally preserve a function's resolved origin
signature so overload selection and value-dependent precision stay stable. That
preservation also froze return metadata that is derived from function children.
Struct constructors therefore kept stale nested-field nullability after their
children changed.
## Reproduction
With Nereids enabled and fallback disabled, run:
```sql
select count(*)
from numbers('number'='2') l
left join numbers('number'='1') r
on l.number = r.number
and length(to_json(named_struct('l', l.number, 'r', r.number))) > 0;
```
The expected result is `2`. Before this change, the stale struct field type
could cause a nullable-to-non-nullable column cast failure in BE.
## Fix
- Add an identity-by-default hook for refreshing only signature metadata
derived from current children when a resolved signature is reused.
- Override the hook for `struct` and `named_struct` so nested return-field
types and nullability are rebuilt without searching for or rebinding an
overload.
- Keep ordinary functions on the exact reused signature, preserving
precision decisions such as the scale chosen for `round_bankers`.
- Make BE return an error status when struct result metadata is inconsistent
with an argument column, rather than reaching a fatal cast/assert path.
## Tests
- FE unit test: `DerivedFunctionSignatureTest` (3 tests, 0 failures),
covering nullable, named, and nested structs plus signature identity/precision
preservation for a regular precision-sensitive function.
- FE build and deployment to a local sandbox completed successfully.
- Regression suite `derived_struct_signature`: 1 suite, 0 failures, covering
LEFT/INNER/RIGHT/FULL joins, `struct`, `named_struct`, nested structs, and
control cases.
- `clang-format-16` check passed.
- The modified BE source and its new test translation unit both pass Clang
16 syntax compilation with the generated build's real include/define flags and
`-Wall -Wextra -Werror`; targeted clang-tidy checks also pass.
- A fresh local BE unit-test tree could not reach test execution because the
host's GCC 11 rejects existing master C++20 code (including
`std::atomic<std::shared_ptr<...>>`) before compiling this target. The new BE
unit test remains included for CI execution.
--
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]