Fix PREWHERE for Merge with different default types#46454
Merged
vdimir merged 2 commits intoClickHouse:masterfrom Feb 17, 2023
Merged
Fix PREWHERE for Merge with different default types#46454vdimir merged 2 commits intoClickHouse:masterfrom
vdimir merged 2 commits intoClickHouse:masterfrom
Conversation
e066165 to
fe6f95c
Compare
1 task
vdimir
reviewed
Feb 16, 2023
tests/queries/0_stateless/01915_merge_prewhere_virtual_column_rand_chao_wang.sql
Outdated
Show resolved
Hide resolved
vdimir
approved these changes
Feb 16, 2023
Member
Author
vs Conflict with #46367, rebasing. |
In case of underlying table has an ALIAS for this column, while in Merge table it is not marked as an alias, there will NOT_FOUND_COLUMN_IN_BLOCK error. Further more, when underlying tables has different default type for the column, i.e. one has ALIAS and another has real column, then you will also get NOT_FOUND_COLUMN_IN_BLOCK, because Merge engine should take care of this. Also this patch reworks how PREWHERE is handled for Merge table, and now if you use PREWHERE on the column that has the same type and default type (ALIAS, ...) then it will be possible, and only if the type differs, it will be prohibited and throw ILLEGAL_PREWHERE error. And last, but not least, also respect this restrictions for optimize_move_to_prewhere. v2: introduce IStorage::supportedPrewhereColumns() v3: Remove excessive condition for PREWHERE in StorageMerge::read() Signed-off-by: Azat Khuzhin <[email protected]>
Signed-off-by: Azat Khuzhin <[email protected]>
415f77e to
c1d1d95
Compare
Member
Author
|
Test failures does not looks related:
The server was working, but apparently was too slow?
It was still trying to read after the query finished, hence the logical error: This is an interesting issue, will take a look. |
This was referenced Feb 24, 2023
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 PREWHERE for Merge with different default types (fixes some
NOT_FOUND_COLUMN_IN_BLOCKwhen the default type for the column differs, also allowPREWHEREwhen the type of column is the same across tables, and prohibit it, only if it differs)In case of underlying table has an ALIAS for this column, while in Merge table it is not marked as an alias, there will NOT_FOUND_COLUMN_IN_BLOCK error.
Further more, when underlying tables has different default type for the column, i.e. one has ALIAS and another has real column, then you will also get NOT_FOUND_COLUMN_IN_BLOCK, because Merge engine should take care of this.
Also this patch reworks how PREWHERE is handled for Merge table, and now if you use PREWHERE on the column that has the same type and default type (ALIAS, ...) then it will be possible, and only if the type differs, it will be prohibited and throw ILLEGAL_PREWHERE error.
And last, but not least, also respect this restrictions for optimize_move_to_prewhere.
Cc: @vdimir
Fixes: #46286