mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Merge pull request #62398 from Avogar/fix-analyzer-merge-push-down
Fix filter pushdown from additional_table_filters in Merge engine in analyzer
This commit is contained in:
commit
057efdb447
@ -814,7 +814,8 @@ JoinTreeQueryPlan buildQueryPlanForTableExpression(QueryTreeNodePtr table_expres
|
||||
bool optimize_move_to_prewhere
|
||||
= settings.optimize_move_to_prewhere && (!is_final || settings.optimize_move_to_prewhere_if_final);
|
||||
|
||||
if (storage->supportsPrewhere() && optimize_move_to_prewhere)
|
||||
auto supported_prewhere_columns = storage->supportedPrewhereColumns();
|
||||
if (storage->canMoveConditionsToPrewhere() && optimize_move_to_prewhere && (!supported_prewhere_columns || supported_prewhere_columns->contains(filter_info.column_name)))
|
||||
{
|
||||
if (!prewhere_info)
|
||||
prewhere_info = std::make_shared<PrewhereInfo>();
|
||||
|
@ -19,6 +19,12 @@ public:
|
||||
bool supportsSampling() const override { return true; }
|
||||
bool supportsFinal() const override { return true; }
|
||||
bool supportsPrewhere() const override { return true; }
|
||||
|
||||
std::optional<NameSet> supportedPrewhereColumns() const override
|
||||
{
|
||||
return original_storage_snapshot ? original_storage_snapshot->storage.supportedPrewhereColumns() : std::nullopt;
|
||||
}
|
||||
|
||||
bool supportsSubcolumns() const override { return true; }
|
||||
bool supportsDynamicSubcolumns() const override { return true; }
|
||||
bool canMoveConditionsToPrewhere() const override
|
||||
|
@ -0,0 +1,3 @@
|
||||
UInt32 1
|
||||
UInt32 2
|
||||
UInt32 3
|
@ -0,0 +1,8 @@
|
||||
set allow_suspicious_low_cardinality_types=1;
|
||||
drop table if exists test;
|
||||
create table test (`x` LowCardinality(Nullable(UInt32)), `y` String) engine = MergeTree order by tuple();
|
||||
insert into test values (1, 'a'), (2, 'bb'), (3, 'ccc'), (4, 'dddd');
|
||||
create table m_table (x UInt32, y String) engine = Merge(currentDatabase(), 'test*');
|
||||
select toTypeName(x), x FROM m_table SETTINGS additional_table_filters = {'m_table':'x != 4'}, optimize_move_to_prewhere=1, allow_experimental_analyzer=1;
|
||||
drop table test;
|
||||
|
Loading…
Reference in New Issue
Block a user