Skip to content

Fix remote predicate pushdown not respect literal types - #77093

Merged
nickitat merged 5 commits into
ClickHouse:masterfrom
canhld94:fix_remote_predicate_pushdown
Mar 6, 2025
Merged

nickitat merged 5 commits into
ClickHouse:masterfrom
canhld94:fix_remote_predicate_pushdown

Conversation

@canhld94

@canhld94 canhld94 commented Mar 4, 2025

Copy link
Copy Markdown
Contributor

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

  • Fix illegal comparison in distributed queries because pushing down predicates to remote doesn't respect literal types.

Reproduce in head: https://fiddle.clickhouse.com/c13009f9-2228-44c5-8c20-36a8cca31622

canhld94 added 3 commits March 4, 2025 06:54
Signed-off-by: Duc Canh Le <[email protected]>
Signed-off-by: Duc Canh Le <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Mar 4, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b4192a7]

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Mar 4, 2025
@nickitat nickitat added the can be tested Allows running workflows for external contributors label Mar 4, 2025
@nickitat nickitat self-assigned this Mar 4, 2025
{
auto literal = std::make_shared<ASTLiteral>((*node->column)[0]);
node_to_ast[node] = std::move(literal);
/// Need to enforce type of the literal, because some type is not comparable to its native type

@nickitat nickitat Mar 4, 2025 •

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.

when I took your example (https://fiddle.clickhouse.com/f6d2dbb1-e863-421a-ab5e-7ef372597947), I saw this query sent to shards:

SELECT `__table1`.`d` AS `d`, count() AS `count()`
FROM `default`.`t` AS `__table1`
WHERE `__table1`.`event` != ''
GROUP BY `__table1`.`d` 
HAVING (`d` >= 20119) AND ((`__table1`.`d` >= _CAST(20119, 'Date')) AND (count() >= 1)

is it right that (d >= 20119) in HAVING comes from the code you've fixed? and now we will send another _CAST(20119, 'Date') instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

when I took your example (https://fiddle.clickhouse.com/f6d2dbb1-e863-421a-ab5e-7ef372597947), I saw this query sent to shards:

SELECT `__table1`.`d` AS `d`, count() AS `count()`
FROM `default`.`t` AS `__table1`
WHERE `__table1`.`event` != ''
GROUP BY `__table1`.`d` 
HAVING (`d` >= 20119) AND ((`__table1`.`d` >= _CAST(20119, 'Date')) AND (count() >= 1)

is it right that (d >= 20119) in HAVING comes from the code you've fixed? and now we will send another _CAST(20119, 'Date') instead?

@nickitat yes. Have to admit that I don't fully understand the remote predicate pushdown logic yet, so can't see why we have duplicated predicates.

@nickitat
nickitat added this pull request to the merge queue Mar 6, 2025
Merged via the queue into ClickHouse:master with commit 8103644 Mar 6, 2025
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants