Repository navigation
Conversation
|
Workflow [PR], commit [4d75b06] Summary: ❌
AI ReviewSummaryThis PR fixes the planner type mismatch for correlated subqueries that reference Findings❌ Blockers
Tests
Final VerdictStatus: ❌ Block Minimum required action: fix or reject nullable correlated-key decorrelation semantics, then cover the executed query result rather than only the action DAG type. |
|
The error stopped causing the failure of the server. and now just silently lives in the query plan. I adjusted the test so that it is seen what should be the result |
| /// actual post-aggregation type from the outer query's plan header if available. | ||
| auto column_type = node->getColumnType(); | ||
| const auto & outer_header = planner_context->getGlobalPlannerContext()->getOuterQueryHeader(); | ||
| if (outer_header && outer_header->has(column_node_name)) |
There was a problem hiding this comment.
This lets correlated keys become Nullable (for example the rollup/grouping-sets rows produced by group_by_use_nulls), but the decorrelation join still compares the correlated identifiers with ordinary Equals in buildLogicalJoin. HashJoin explicitly skips rows with NULLs in join keys, so a NULL outer key will not join back to the subquery row that was evaluated with that same NULL value.
That changes correlated-subquery semantics for the rows this PR is trying to support. A minimal shape is:
SET enable_analyzer = 1, allow_experimental_correlated_subqueries = 1, group_by_use_nulls = 1;
SELECT number, (SELECT isNull(number))
FROM numbers(1)
GROUP BY number WITH ROLLUP;The rollup row should evaluate the subquery with number = NULL and return 1, but with a regular join predicate the NULL key is treated as no match and the scalar result is filled from the outer join default instead. Please make the correlated-key join NULL-safe when the key type is nullable, or keep these nullable-key cases unsupported until the join semantics are fixed, and add a regression that checks the executed query result rather than only the EXPLAIN actions type.
…lickHouse/ClickHouse into fix_fuzzer_grouping_by_use_nulls_error
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 40/41 (97.56%) | Lost baseline coverage: none · Uncovered code |
|
Dear @novikd, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
| SELECT replaceRegexpOne(trim(explain), ' : [0-9]+$', '') AS planner_action | ||
| FROM ( | ||
| EXPLAIN actions = 1, compact = 0, pretty = 0 | ||
| SELECT bitNot((SELECT bitNot(number))) | ||
| FROM numbers(1) | ||
| GROUP BY number WITH ROLLUP | ||
| ) |
There was a problem hiding this comment.
It should be fixed in the QueryAnalyzer not in the Planner. The analyzed Query Tree is invalid: https://fiddle.clickhouse.com/0782ad74-9b45-4eff-a6e6-8aeb0c7ee2e5
|
Dear @novikd, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
|
I verified the current state of this on
Regarding the AI review's concern about Since the So this PR appears to be fully superseded by #100365 and can be closed. Thank you for the investigation here, @Fgrtue — it correctly identified the type divergence; the analyzer-side fix ultimately landed via the other PR. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Documentation entry for user-facing changes
Resolves #102273.
The investigation shows that the error happens when we use setting
group_by_use_nulls = 1, and correlated subqeuries, then we wrap the types of grouped elements into Nullable, while correlated subquery does not account for such a change.That is why the fix is: after we built the plan for outer query, and start building correlated subquery, provide the header of columns to the correlated subquery, so that when visiting correlated column we fix its type if it diverges from the one in the outer query.