New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix PREWHERE for Merge with different default types #46454
Conversation
e066165
to
fe6f95c
Compare
tests/queries/0_stateless/01915_merge_prewhere_virtual_column_rand_chao_wang.sql
Show resolved
Hide resolved
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 <a.khuzhin@semrush.com>
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
415f77e
to
c1d1d95
Compare
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. |
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_BLOCK
when the default type for the column differs, also allowPREWHERE
when 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