englefly opened a new pull request, #70918: URL: https://github.com/apache/doris/pull/70918
### Background Nereids represents a lateral UNNEST join as a generate operator with a list of generators and the join's ON predicates. Physical plan visitors use the operator's expression list to inspect expressions it evaluates. ### What problem does this PR solve? Issue Number: None Related PR: #58228 (introduced lateral UNNEST conjuncts), #70516 (review identified the missing expressions) PR Type: Bugfix Problem Summary: For `JOIN LATERAL UNNEST(xs) AS t(x) ON assert_true(x > 0, 'bad')`, the physical generate expression list omits the assertion. A visitor that relies on the list to detect non-movable expressions can miss it. Include the ON predicates in the expression list and validate them against the child and generated columns. ### Details - **Frequency:** Always when an expression visitor reads a physical generate with a lateral ON predicate. - **Root cause:** `PhysicalGenerate.getExpressions()` enumerates the generators. The ON predicates are stored separately in `getConjuncts()` and are translated into the execution plan. - **Why existing tests missed it:** `GenerateConjunctRewriteTest` exercises logical ExprId rewriting. `TopnLazyMaterializeTest` covered lateral predicate inputs through a special case in lazy materialization. The `nereids_unnest_fn` and `topn_lazy_order_by_alias` SQL suites exercise join results and materialization plans. The physical expression list was untested. - **Fix:** Include the ON predicates in the physical expression list. Validate generator arguments against child outputs and validate ON predicates against child and generated outputs. Use the physical generate's input-slot set to keep the predicate's child columns materialized. - **Other paths and branches:** `LogicalGenerate` already includes ON predicates. The omission was introduced by #58228 and is present on branches 4.1 and 4.2. The checked 3.1 and 4.0 branches have no lateral ON conjuncts on `PhysicalGenerate`. - **Behavior change:** Physical plan validation reports unavailable slots in lateral ON predicates. The error identifies the slot and the IDs available for that expression. ### Testing - `PhysicalGenerateTest` passed locally. It asserts that the list contains both the generator and the assertion, then checks valid and unavailable ON slots. The baseline expression list was checked in source and contains only the generator. - `GenerateConjunctRewriteTest` and `TopnLazyMaterializeTest.testLateralGenerateConjunctKeepsItsAliasSourceMaterialized` passed in the same FE unit test run. - FE core Checkstyle passed with zero violations. ### Release note Physical plan checks now account for lateral UNNEST join predicates. ### Check List (For Author) - Behavior changed: Yes (see Details) - Does this need documentation: No - Pre-submission status: Ready ### AI Disclosure - Tool: OpenAI Codex (GPT-6) - Generated: Code, tests, and PR description - Human review: not stated -- 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]
