Skip to content

Fix logical error in ARRAY JOIN when one of the table columns is empty tuple column#91123

Merged
nihalzp merged 5 commits intoClickHouse:masterfrom
nihalzp:array-join-empty-tuple
Dec 12, 2025
Merged

Fix logical error in ARRAY JOIN when one of the table columns is empty tuple column#91123
nihalzp merged 5 commits intoClickHouse:masterfrom
nihalzp:array-join-empty-tuple

Conversation

@nihalzp
Copy link
Copy Markdown
Member

@nihalzp nihalzp commented Nov 28, 2025

The following query has logical error:

CREATE TABLE t0 (c0 Array(Int), c1 Tuple()) ENGINE = MergeTree() ORDER BY tuple();

INSERT INTO t0 (c0, c1) VALUES ([1], ()), ([], ());

SELECT * FROM t0 ARRAY JOIN c0 ORDER BY c1;

Changelog category (leave one):

  • Critical Bug Fix (crash, data loss, RBAC) or LOGICAL_ERROR

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fix logical error in ARRAY JOIN when one of the table columns is empty tuple column. Closes #90801.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Nov 28, 2025

Workflow [PR], commit [e02e39f]

Summary:

job_name test_name status info comment
BuzzHouse (amd_debug) failure
Logical error: 'Inconsistent AST formatting in Function_not: the query: FAIL cidb, issue

@clickhouse-gh clickhouse-gh bot added pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! labels Nov 28, 2025
@nihalzp nihalzp added v25.10-must-backport v25.11-must-backport and removed pr-must-backport Pull request should be backported intentionally. Use this label with great care! labels Nov 28, 2025
@nihalzp nihalzp changed the title Fix logical error in ARRAY JOIN when one of the table column is empty tuple column Fix logical error in ARRAY JOIN when one of the table columns is empty tuple column Nov 28, 2025
@yariks5s yariks5s self-assigned this Nov 28, 2025
@nihalzp nihalzp added this pull request to the merge queue Dec 5, 2025
@nihalzp nihalzp removed this pull request from the merge queue due to a manual request Dec 5, 2025
ErrorCodes::SIZES_OF_COLUMNS_DOESNT_MATCH, "Size of indexes ({}) is less than required ({})", indexes.size(), result_size);

return cloneResized(limit ? limit : column_length);
return cloneResized(result_size);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a similar bug in ColumnTuple::permute. Let's also fix it here.
Also there is a bug in ColumnTuple::expand, the result size should be mask.size(), not countBytesInFilter(mask). Let's also fix it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching it! I have tried to fix it and added unit tests.

@nihalzp nihalzp requested a review from Avogar December 12, 2025 14:47
@nihalzp nihalzp added this pull request to the merge queue Dec 12, 2025
Merged via the queue into ClickHouse:master with commit cc876e4 Dec 12, 2025
248 of 256 checks passed
@nihalzp nihalzp deleted the array-join-empty-tuple branch December 12, 2025 19:17
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Dec 12, 2025
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Dec 12, 2025
robot-clickhouse-ci-2 added a commit that referenced this pull request Dec 12, 2025
Cherry pick #91123 to 25.10: Fix logical error in `ARRAY JOIN` when one of the table columns is empty tuple column
robot-clickhouse added a commit that referenced this pull request Dec 12, 2025
…of the table columns is empty tuple column
robot-clickhouse-ci-2 added a commit that referenced this pull request Dec 12, 2025
Cherry pick #91123 to 25.11: Fix logical error in `ARRAY JOIN` when one of the table columns is empty tuple column
robot-clickhouse added a commit that referenced this pull request Dec 12, 2025
…of the table columns is empty tuple column
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Dec 12, 2025
clickhouse-gh bot added a commit that referenced this pull request Dec 12, 2025
Backport #91123 to 25.11: Fix logical error in `ARRAY JOIN` when one of the table columns is empty tuple column
clickhouse-gh bot added a commit that referenced this pull request Dec 13, 2025
Backport #91123 to 25.10: Fix logical error in `ARRAY JOIN` when one of the table columns is empty tuple column
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-critical-bugfix pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v25.10-must-backport v25.11-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Another Invalid number of rows in Chunk with empty tuple

6 participants