mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-19 04:42:37 +00:00
Fix Not-ready Set in JOIN ON (IN subquery) with old analyzer.
This commit is contained in:
parent
b6a1a0afbb
commit
f2cd222f19
@ -1073,12 +1073,13 @@ static std::shared_ptr<IJoin> chooseJoinAlgorithm(
|
||||
|
||||
static std::unique_ptr<QueryPlan> buildJoinedPlan(
|
||||
ContextPtr context,
|
||||
PreparedSetsPtr prepared_sets,
|
||||
const ASTTablesInSelectQueryElement & join_element,
|
||||
TableJoin & analyzed_join,
|
||||
SelectQueryOptions query_options)
|
||||
{
|
||||
/// Actions which need to be calculated on joined block.
|
||||
auto joined_block_actions = analyzed_join.createJoinedBlockActions(context);
|
||||
auto joined_block_actions = analyzed_join.createJoinedBlockActions(context, std::move(prepared_sets));
|
||||
NamesWithAliases required_columns_with_aliases = analyzed_join.getRequiredColumns(
|
||||
Block(joined_block_actions.getResultColumns()), joined_block_actions.getRequiredColumns().getNames());
|
||||
|
||||
@ -1184,7 +1185,7 @@ JoinPtr SelectQueryExpressionAnalyzer::makeJoin(
|
||||
|
||||
if (auto storage = analyzed_join->getStorageJoin())
|
||||
{
|
||||
auto joined_block_actions = analyzed_join->createJoinedBlockActions(getContext());
|
||||
auto joined_block_actions = analyzed_join->createJoinedBlockActions(getContext(), getPreparedSets());
|
||||
NamesWithAliases required_columns_with_aliases = analyzed_join->getRequiredColumns(
|
||||
Block(joined_block_actions.getResultColumns()), joined_block_actions.getRequiredColumns().getNames());
|
||||
|
||||
@ -1197,7 +1198,7 @@ JoinPtr SelectQueryExpressionAnalyzer::makeJoin(
|
||||
return storage->getJoinLocked(analyzed_join, getContext(), original_right_column_names);
|
||||
}
|
||||
|
||||
joined_plan = buildJoinedPlan(getContext(), join_element, *analyzed_join, query_options);
|
||||
joined_plan = buildJoinedPlan(getContext(), getPreparedSets(), join_element, *analyzed_join, query_options);
|
||||
|
||||
const ColumnsWithTypeAndName & right_columns = joined_plan->getCurrentHeader().getColumnsWithTypeAndName();
|
||||
std::tie(left_convert_actions, right_convert_actions) = analyzed_join->createConvertingActions(left_columns, right_columns);
|
||||
|
@ -126,7 +126,7 @@ public:
|
||||
* That is, you need to call getSetsWithSubqueries after all calls of `append*` or `getActions`
|
||||
* and create all the returned sets before performing the actions.
|
||||
*/
|
||||
PreparedSetsPtr getPreparedSets() { return prepared_sets; }
|
||||
PreparedSetsPtr & getPreparedSets() { return prepared_sets; }
|
||||
|
||||
/// Get intermediates for tests
|
||||
const ExpressionAnalyzerData & getAnalyzedData() const { return *this; }
|
||||
|
@ -300,7 +300,7 @@ private:
|
||||
/// This code is partial copy-paste from ExpressionAnalyzer.
|
||||
if (data.table_join)
|
||||
{
|
||||
auto joined_block_actions = data.table_join->createJoinedBlockActions(data.getContext());
|
||||
auto joined_block_actions = data.table_join->createJoinedBlockActions(data.getContext(), data.prepared_sets);
|
||||
NamesWithAliases required_columns_with_aliases = data.table_join->getRequiredColumns(
|
||||
Block(joined_block_actions.getResultColumns()), joined_block_actions.getRequiredColumns().getNames());
|
||||
|
||||
|
@ -1012,11 +1012,13 @@ bool TableJoin::allowParallelHashJoin() const
|
||||
return true;
|
||||
}
|
||||
|
||||
ActionsDAG TableJoin::createJoinedBlockActions(ContextPtr context) const
|
||||
ActionsDAG TableJoin::createJoinedBlockActions(ContextPtr context, PreparedSetsPtr prepared_sets) const
|
||||
{
|
||||
ASTPtr expression_list = rightKeysList();
|
||||
auto syntax_result = TreeRewriter(context).analyze(expression_list, columnsFromJoinedTable());
|
||||
return ExpressionAnalyzer(expression_list, syntax_result, context).getActionsDAG(true, false);
|
||||
ExpressionAnalyzer analyzer(expression_list, syntax_result, context);
|
||||
analyzer.getPreparedSets() = std::move(prepared_sets);
|
||||
return analyzer.getActionsDAG(true, false);
|
||||
}
|
||||
|
||||
size_t TableJoin::getMaxMemoryUsage() const
|
||||
|
@ -47,6 +47,8 @@ struct Settings;
|
||||
class IVolume;
|
||||
using VolumePtr = std::shared_ptr<IVolume>;
|
||||
|
||||
class PreparedSets;
|
||||
using PreparedSetsPtr = std::shared_ptr<PreparedSets>;
|
||||
class TableJoin
|
||||
{
|
||||
public:
|
||||
@ -280,7 +282,7 @@ public:
|
||||
void assertEnableEnalyzer() const;
|
||||
TemporaryDataOnDiskScopePtr getTempDataOnDisk() { return tmp_data ? tmp_data->childScope(CurrentMetrics::TemporaryFilesForJoin) : nullptr; }
|
||||
|
||||
ActionsDAG createJoinedBlockActions(ContextPtr context) const;
|
||||
ActionsDAG createJoinedBlockActions(ContextPtr context, PreparedSetsPtr prepared_sets) const;
|
||||
|
||||
const std::vector<JoinAlgorithm> & getEnabledJoinAlgorithms() const { return join_algorithm; }
|
||||
|
||||
|
@ -0,0 +1,2 @@
|
||||
42 42
|
||||
42 42
|
@ -0,0 +1,3 @@
|
||||
with l_t as (select 42 as key) select * from l_t inner join numbers(50) as r_t on l_t.key = r_t.number and r_t.number in (select number * 2 from numbers(1e3)) settings allow_experimental_analyzer=0;
|
||||
with l_t as (select 42 as key) select * from l_t inner join numbers(50) as r_t on l_t.key = r_t.number and r_t.number in (select number * 2 from numbers(1e3)) settings allow_experimental_analyzer=1;
|
||||
|
Loading…
Reference in New Issue
Block a user