mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 17:41:59 +00:00
Fix 02382_join_and_filtering_set
Copy missing corresponding code from Interpreter, adjust test (removed with cube)
This commit is contained in:
parent
16eeec69bf
commit
84e838d038
@ -1248,7 +1248,26 @@ JoinTreeQueryPlan buildQueryPlanForJoinNode(const QueryTreeNodePtr & join_table_
|
||||
const auto & join_clause = table_join->getOnlyClause();
|
||||
|
||||
bool kind_allows_filtering = isInner(join_kind) || isLeft(join_kind) || isRight(join_kind);
|
||||
if (settings.max_rows_in_set_to_optimize_join > 0 && kind_allows_filtering)
|
||||
|
||||
auto has_non_const = [](const Block & block, const auto & keys)
|
||||
{
|
||||
for (const auto & key : keys)
|
||||
{
|
||||
const auto & column = block.getByName(key).column;
|
||||
if (column && !isColumnConst(*column))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/// This optimization relies on the sorting that should buffer the whole stream before emitting any rows.
|
||||
/// It doesn't hold such a guarantee for streams with const keys.
|
||||
/// Note: it's also doesn't work with the read-in-order optimization.
|
||||
/// No checks here because read in order is not applied if we have `CreateSetAndFilterOnTheFlyStep` in the pipeline between the reading and sorting steps.
|
||||
bool has_non_const_keys = has_non_const(left_plan.getCurrentDataStream().header, join_clause.key_names_left)
|
||||
&& has_non_const(right_plan.getCurrentDataStream().header, join_clause.key_names_right);
|
||||
|
||||
if (settings.max_rows_in_set_to_optimize_join > 0 && kind_allows_filtering && has_non_const_keys)
|
||||
{
|
||||
auto * left_set = add_create_set(left_plan, join_clause.key_names_left, JoinTableSide::Left);
|
||||
auto * right_set = add_create_set(right_plan, join_clause.key_names_right, JoinTableSide::Right);
|
||||
|
@ -82,7 +82,6 @@
|
||||
02354_annoy
|
||||
02366_union_decimal_conversion
|
||||
02375_rocksdb_with_filters
|
||||
02382_join_and_filtering_set
|
||||
02402_merge_engine_with_view
|
||||
02404_memory_bound_merging
|
||||
02426_orc_bug
|
||||
|
@ -7,8 +7,5 @@
|
||||
10
|
||||
bug with constant columns in join keys
|
||||
a a
|
||||
a a
|
||||
a a
|
||||
a a
|
||||
1
|
||||
1
|
||||
|
@ -22,20 +22,20 @@ SELECT count() FROM t1 JOIN t2 ON t1.x = t2.x WHERE t1.x % 2 == 0 AND t2.x % 2 =
|
||||
SELECT 'bug with constant columns in join keys';
|
||||
|
||||
SELECT * FROM ( SELECT 'a' AS key ) AS t1
|
||||
INNER JOIN ( SELECT 'a' AS key GROUP BY ignore(1), ignore(2) WITH CUBE ) AS t2
|
||||
INNER JOIN ( SELECT 'a' AS key ) AS t2
|
||||
ON t1.key = t2.key
|
||||
;
|
||||
|
||||
SELECT count() > 1 FROM (EXPLAIN PIPELINE
|
||||
SELECT * FROM ( SELECT materialize('a') AS key ) AS t1
|
||||
INNER JOIN ( SELECT materialize('a') AS key GROUP BY ignore(1), ignore(2) WITH CUBE ) AS t2
|
||||
INNER JOIN ( SELECT materialize('a') AS key ) AS t2
|
||||
ON t1.key = t2.key
|
||||
) WHERE explain ilike '%FilterBySetOnTheFlyTransform%'
|
||||
;
|
||||
|
||||
SELECT count() == 0 FROM (EXPLAIN PIPELINE
|
||||
SELECT * FROM ( SELECT 'a' AS key ) AS t1
|
||||
INNER JOIN ( SELECT 'a' AS key GROUP BY ignore(1), ignore(2) WITH CUBE ) AS t2
|
||||
INNER JOIN ( SELECT 'a' AS key ) AS t2
|
||||
ON t1.key = t2.key
|
||||
) WHERE explain ilike '%FilterBySetOnTheFlyTransform%'
|
||||
;
|
||||
|
Loading…
Reference in New Issue
Block a user