Repository navigation
Fixing constants in GROUP BY keys with analyzer (again) - #66433
Merged
Merged
Conversation
KochetovNicolai
commented
Jul 12, 2024
| * Result: SELECT 2; | ||
| */ | ||
| if (function_base->isSuitableForConstantFolding() && !disable_constant_folding) | ||
| if (function_base->isSuitableForConstantFolding()) // && !disable_constant_folding) |
Member
Author
There was a problem hiding this comment.
Currently, I want to check what tests it breaks.
Member
|
This is an automated comment for commit 00fa457 with description of existing statuses. It's updated for the latest CI running ❌ Click here to open a full report in a separate page
Successful checks
|
novikd
reviewed
Jul 15, 2024
| { | ||
| /// Do not allow removing constants like `hostName()` | ||
| if (!function_node->getFunctionOrThrow()->isDeterministic()) | ||
| if (function_node->getFunctionOrThrow()->isServerConstant()) |
Member
There was a problem hiding this comment.
Will it work for random functions?
Member
Author
There was a problem hiding this comment.
Random does not return constant result, so no constant folding.
For randConst we constant fold and substitute result to constant and remove it from GROUP BY key.
SELECT
count(),
randConstant() AS c1
FROM remote('127.0.0.{3,2}', system, one)
GROUP BY c1
SETTINGS allow_experimental_analyzer = 1
Query id: 15fef62f-a79a-4088-a3b2-44bf5259b2b4
┌─count()─┬────────c1─┐
1. │ 2 │ 563172653 │
└─────────┴───────────┘
The issue is only for special functions that are not constant on the initiator (so they are not substituted to constants) but constant on the replica and removed from the GROUP BY key.
This was referenced Jul 16, 2024
robot-clickhouse
added a commit
that referenced
this pull request
Jul 16, 2024
robot-ch-test-poll
added a commit
that referenced
this pull request
Jul 16, 2024
Backport #66433 to 24.6: Fixing constants in GROUP BY keys with analyzer (again)
robot-clickhouse
added a commit
that referenced
this pull request
Jul 23, 2024
robot-clickhouse
added a commit
that referenced
this pull request
Jul 23, 2024
robot-clickhouse
added a commit
that referenced
this pull request
Jul 23, 2024
robot-ch-test-poll1
added a commit
that referenced
this pull request
Jul 23, 2024
Backport #66433 to 24.5: Fixing constants in GROUP BY keys with analyzer (again)
robot-ch-test-poll
added a commit
that referenced
this pull request
Jul 23, 2024
Backport #66433 to 24.4: Fixing constants in GROUP BY keys with analyzer (again)
robot-clickhouse-ci-1
added a commit
that referenced
this pull request
Jul 23, 2024
Backport #66433 to 24.3: Fixing constants in GROUP BY keys with analyzer (again)
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix
Cannot find columnerror for queries with constant expression inGROUP BYkey and new analyzer enabled.Fixes #65468 (which was broken after #64519)