::joinBlockImpl(
block.safeGetByPosition(pos).column = block.safeGetByPosition(pos).column->replicate(*offsets_to_replicate);
}
}
- block.erase(block_columns_to_erase);
return remaining_block;
}
diff --git a/src/Interpreters/InterpreterSelectQuery.cpp b/src/Interpreters/InterpreterSelectQuery.cpp
index 8ddf51fa25e..3918c1c37ea 100644
--- a/src/Interpreters/InterpreterSelectQuery.cpp
+++ b/src/Interpreters/InterpreterSelectQuery.cpp
@@ -1888,9 +1888,7 @@ void InterpreterSelectQuery::executeImpl(QueryPlan & query_plan, std::optionalsetStepDescription(fmt::format("JOIN {}", expressions.join->pipelineType()));
std::vector plans;
diff --git a/src/Interpreters/TableJoin.cpp b/src/Interpreters/TableJoin.cpp
index 555aaff2e06..2532dddba3c 100644
--- a/src/Interpreters/TableJoin.cpp
+++ b/src/Interpreters/TableJoin.cpp
@@ -41,7 +41,6 @@ namespace DB
namespace Setting
{
extern const SettingsBool allow_experimental_join_right_table_sorting;
- extern const SettingsBool allow_experimental_analyzer;
extern const SettingsUInt64 cross_join_min_bytes_to_compress;
extern const SettingsUInt64 cross_join_min_rows_to_compress;
extern const SettingsUInt64 default_max_bytes_in_join;
@@ -144,7 +143,6 @@ TableJoin::TableJoin(const Settings & settings, VolumePtr tmp_volume_, Temporary
, max_memory_usage(settings[Setting::max_memory_usage])
, tmp_volume(tmp_volume_)
, tmp_data(tmp_data_)
- , enable_analyzer(settings[Setting::allow_experimental_analyzer])
{
}
@@ -163,8 +161,6 @@ void TableJoin::resetCollected()
clauses.clear();
columns_from_joined_table.clear();
columns_added_by_join.clear();
- columns_from_left_table.clear();
- result_columns_from_left_table.clear();
original_names.clear();
renames.clear();
left_type_map.clear();
@@ -207,20 +203,6 @@ size_t TableJoin::rightKeyInclusion(const String & name) const
return count;
}
-void TableJoin::setInputColumns(NamesAndTypesList left_output_columns, NamesAndTypesList right_output_columns)
-{
- columns_from_left_table = std::move(left_output_columns);
- columns_from_joined_table = std::move(right_output_columns);
-}
-
-
-const NamesAndTypesList & TableJoin::getOutputColumns(JoinTableSide side)
-{
- if (side == JoinTableSide::Left)
- return result_columns_from_left_table;
- return columns_added_by_join;
-}
-
void TableJoin::deduplicateAndQualifyColumnNames(const NameSet & left_table_columns, const String & right_table_prefix)
{
NameSet joined_columns;
@@ -369,18 +351,9 @@ bool TableJoin::rightBecomeNullable(const DataTypePtr & column_type) const
return forceNullableRight() && JoinCommon::canBecomeNullable(column_type);
}
-void TableJoin::setUsedColumn(const NameAndTypePair & joined_column, JoinTableSide side)
-{
- if (side == JoinTableSide::Left)
- result_columns_from_left_table.push_back(joined_column);
- else
- columns_added_by_join.push_back(joined_column);
-
-}
-
void TableJoin::addJoinedColumn(const NameAndTypePair & joined_column)
{
- setUsedColumn(joined_column, JoinTableSide::Right);
+ columns_added_by_join.emplace_back(joined_column);
}
NamesAndTypesList TableJoin::correctedColumnsAddedByJoin() const
@@ -1022,32 +995,5 @@ size_t TableJoin::getMaxMemoryUsage() const
return max_memory_usage;
}
-void TableJoin::swapSides()
-{
- assertEnableEnalyzer();
-
- std::swap(key_asts_left, key_asts_right);
- std::swap(left_type_map, right_type_map);
- for (auto & clause : clauses)
- {
- std::swap(clause.key_names_left, clause.key_names_right);
- std::swap(clause.on_filter_condition_left, clause.on_filter_condition_right);
- std::swap(clause.analyzer_left_filter_condition_column_name, clause.analyzer_right_filter_condition_column_name);
- }
-
- std::swap(columns_from_left_table, columns_from_joined_table);
- std::swap(result_columns_from_left_table, columns_added_by_join);
-
- if (table_join.kind == JoinKind::Left)
- table_join.kind = JoinKind::Right;
- else if (table_join.kind == JoinKind::Right)
- table_join.kind = JoinKind::Left;
-}
-
-void TableJoin::assertEnableEnalyzer() const
-{
- if (!enable_analyzer)
- throw DB::Exception(ErrorCodes::NOT_IMPLEMENTED, "TableJoin: analyzer is disabled");
-}
}
diff --git a/src/Interpreters/TableJoin.h b/src/Interpreters/TableJoin.h
index e0e1926fb12..e1bae55a4ed 100644
--- a/src/Interpreters/TableJoin.h
+++ b/src/Interpreters/TableJoin.h
@@ -167,9 +167,6 @@ private:
ASOFJoinInequality asof_inequality = ASOFJoinInequality::GreaterOrEquals;
- NamesAndTypesList columns_from_left_table;
- NamesAndTypesList result_columns_from_left_table;
-
/// All columns which can be read from joined table. Duplicating names are qualified.
NamesAndTypesList columns_from_joined_table;
/// Columns will be added to block by JOIN.
@@ -205,8 +202,6 @@ private:
bool is_join_with_constant = false;
- bool enable_analyzer = false;
-
Names requiredJoinedNames() const;
/// Create converting actions and change key column names if required
@@ -271,8 +266,6 @@ public:
VolumePtr getGlobalTemporaryVolume() { return tmp_volume; }
TemporaryDataOnDiskScopePtr getTempDataOnDisk() { return tmp_data; }
- bool enableEnalyzer() const { return enable_analyzer; }
- void assertEnableEnalyzer() const;
ActionsDAG createJoinedBlockActions(ContextPtr context) const;
@@ -289,7 +282,6 @@ public:
}
bool allowParallelHashJoin() const;
- void swapSides();
bool joinUseNulls() const { return join_use_nulls; }
@@ -380,9 +372,6 @@ public:
bool leftBecomeNullable(const DataTypePtr & column_type) const;
bool rightBecomeNullable(const DataTypePtr & column_type) const;
void addJoinedColumn(const NameAndTypePair & joined_column);
-
- void setUsedColumn(const NameAndTypePair & joined_column, JoinTableSide side);
-
void setColumnsAddedByJoin(const NamesAndTypesList & columns_added_by_join_value)
{
columns_added_by_join = columns_added_by_join_value;
@@ -408,17 +397,11 @@ public:
ASTPtr leftKeysList() const;
ASTPtr rightKeysList() const; /// For ON syntax only
- void setColumnsFromJoinedTable(NamesAndTypesList columns_from_joined_table_value, const NameSet & left_table_columns, const String & right_table_prefix, const NamesAndTypesList & columns_from_left_table_)
+ void setColumnsFromJoinedTable(NamesAndTypesList columns_from_joined_table_value, const NameSet & left_table_columns, const String & right_table_prefix)
{
columns_from_joined_table = std::move(columns_from_joined_table_value);
deduplicateAndQualifyColumnNames(left_table_columns, right_table_prefix);
- result_columns_from_left_table = columns_from_left_table_;
- columns_from_left_table = columns_from_left_table_;
}
-
- void setInputColumns(NamesAndTypesList left_output_columns, NamesAndTypesList right_output_columns);
- const NamesAndTypesList & getOutputColumns(JoinTableSide side);
-
const NamesAndTypesList & columnsFromJoinedTable() const { return columns_from_joined_table; }
const NamesAndTypesList & columnsAddedByJoin() const { return columns_added_by_join; }
diff --git a/src/Interpreters/TreeRewriter.cpp b/src/Interpreters/TreeRewriter.cpp
index 28e11166762..ea08fd92339 100644
--- a/src/Interpreters/TreeRewriter.cpp
+++ b/src/Interpreters/TreeRewriter.cpp
@@ -1353,15 +1353,12 @@ TreeRewriterResultPtr TreeRewriter::analyzeSelect(
if (tables_with_columns.size() > 1)
{
- auto columns_from_left_table = tables_with_columns[0].columns;
const auto & right_table = tables_with_columns[1];
auto columns_from_joined_table = right_table.columns;
/// query can use materialized or aliased columns from right joined table,
/// we want to request it for right table
columns_from_joined_table.insert(columns_from_joined_table.end(), right_table.hidden_columns.begin(), right_table.hidden_columns.end());
- columns_from_left_table.insert(columns_from_left_table.end(), tables_with_columns[0].hidden_columns.begin(), tables_with_columns[0].hidden_columns.end());
- result.analyzed_join->setColumnsFromJoinedTable(
- std::move(columns_from_joined_table), source_columns_set, right_table.table.getQualifiedNamePrefix(), columns_from_left_table);
+ result.analyzed_join->setColumnsFromJoinedTable(std::move(columns_from_joined_table), source_columns_set, right_table.table.getQualifiedNamePrefix());
}
translateQualifiedNames(query, *select_query, source_columns_set, tables_with_columns);
diff --git a/src/Parsers/ASTColumnDeclaration.cpp b/src/Parsers/ASTColumnDeclaration.cpp
index e7c3fdbb548..1c7d72bafcc 100644
--- a/src/Parsers/ASTColumnDeclaration.cpp
+++ b/src/Parsers/ASTColumnDeclaration.cpp
@@ -128,4 +128,14 @@ void ASTColumnDeclaration::formatImpl(const FormatSettings & format_settings, Fo
}
}
+void ASTColumnDeclaration::forEachPointerToChild(std::function f)
+{
+ f(reinterpret_cast(&default_expression));
+ f(reinterpret_cast(&comment));
+ f(reinterpret_cast(&codec));
+ f(reinterpret_cast(&statistics_desc));
+ f(reinterpret_cast(&ttl));
+ f(reinterpret_cast(&collation));
+ f(reinterpret_cast(&settings));
+}
}
diff --git a/src/Parsers/ASTColumnDeclaration.h b/src/Parsers/ASTColumnDeclaration.h
index 914916d5074..0c5076f0201 100644
--- a/src/Parsers/ASTColumnDeclaration.h
+++ b/src/Parsers/ASTColumnDeclaration.h
@@ -29,6 +29,9 @@ public:
ASTPtr clone() const override;
void formatImpl(const FormatSettings & format_settings, FormatState & state, FormatStateStacked frame) const override;
+
+protected:
+ void forEachPointerToChild(std::function f) override;
};
}
diff --git a/src/Parsers/ASTOrderByElement.cpp b/src/Parsers/ASTOrderByElement.cpp
index 09193a8b5e1..d87c296d398 100644
--- a/src/Parsers/ASTOrderByElement.cpp
+++ b/src/Parsers/ASTOrderByElement.cpp
@@ -54,6 +54,11 @@ void ASTOrderByElement::formatImpl(const FormatSettings & settings, FormatState
settings.ostr << (settings.hilite ? hilite_keyword : "") << " STEP " << (settings.hilite ? hilite_none : "");
fill_step->formatImpl(settings, state, frame);
}
+ if (auto fill_staleness = getFillStaleness())
+ {
+ settings.ostr << (settings.hilite ? hilite_keyword : "") << " STALENESS " << (settings.hilite ? hilite_none : "");
+ fill_staleness->formatImpl(settings, state, frame);
+ }
}
}
diff --git a/src/Parsers/ASTOrderByElement.h b/src/Parsers/ASTOrderByElement.h
index 6edf84d7bde..4dc35dac217 100644
--- a/src/Parsers/ASTOrderByElement.h
+++ b/src/Parsers/ASTOrderByElement.h
@@ -18,6 +18,7 @@ private:
FILL_FROM,
FILL_TO,
FILL_STEP,
+ FILL_STALENESS,
};
public:
@@ -32,12 +33,14 @@ public:
void setFillFrom(ASTPtr node) { setChild(Child::FILL_FROM, node); }
void setFillTo(ASTPtr node) { setChild(Child::FILL_TO, node); }
void setFillStep(ASTPtr node) { setChild(Child::FILL_STEP, node); }
+ void setFillStaleness(ASTPtr node) { setChild(Child::FILL_STALENESS, node); }
/** Collation for locale-specific string comparison. If empty, then sorting done by bytes. */
ASTPtr getCollation() const { return getChild(Child::COLLATION); }
ASTPtr getFillFrom() const { return getChild(Child::FILL_FROM); }
ASTPtr getFillTo() const { return getChild(Child::FILL_TO); }
ASTPtr getFillStep() const { return getChild(Child::FILL_STEP); }
+ ASTPtr getFillStaleness() const { return getChild(Child::FILL_STALENESS); }
String getID(char) const override { return "OrderByElement"; }
diff --git a/src/Parsers/CommonParsers.h b/src/Parsers/CommonParsers.h
index dd0ba91d428..c02f8d06323 100644
--- a/src/Parsers/CommonParsers.h
+++ b/src/Parsers/CommonParsers.h
@@ -546,6 +546,7 @@ namespace DB
MR_MACROS(YY, "YY") \
MR_MACROS(YYYY, "YYYY") \
MR_MACROS(ZKPATH, "ZKPATH") \
+ MR_MACROS(STALENESS, "STALENESS") \
/// The list of keywords where underscore is intentional
#define APPLY_FOR_PARSER_KEYWORDS_WITH_UNDERSCORES(MR_MACROS) \
diff --git a/src/Parsers/CreateQueryUUIDs.cpp b/src/Parsers/CreateQueryUUIDs.cpp
index 70848440a0e..c788cc7a025 100644
--- a/src/Parsers/CreateQueryUUIDs.cpp
+++ b/src/Parsers/CreateQueryUUIDs.cpp
@@ -31,7 +31,7 @@ CreateQueryUUIDs::CreateQueryUUIDs(const ASTCreateQuery & query, bool generate_r
/// If we generate random UUIDs for already existing tables then those UUIDs will not be correct making those inner target table inaccessible.
/// Thus it's not safe for example to replace
/// "ATTACH MATERIALIZED VIEW mv AS SELECT a FROM b" with
- /// "ATTACH MATERIALIZED VIEW mv TO INNER UUID '123e4567-e89b-12d3-a456-426614174000' AS SELECT a FROM b"
+ /// "ATTACH MATERIALIZED VIEW mv TO INNER UUID "XXXX" AS SELECT a FROM b"
/// This replacement is safe only for CREATE queries when inner target tables don't exist yet.
if (!query.attach)
{
diff --git a/src/Parsers/ExpressionElementParsers.cpp b/src/Parsers/ExpressionElementParsers.cpp
index 31efcb16f02..ad062d27a37 100644
--- a/src/Parsers/ExpressionElementParsers.cpp
+++ b/src/Parsers/ExpressionElementParsers.cpp
@@ -2178,6 +2178,7 @@ bool ParserOrderByElement::parseImpl(Pos & pos, ASTPtr & node, Expected & expect
ParserKeyword from(Keyword::FROM);
ParserKeyword to(Keyword::TO);
ParserKeyword step(Keyword::STEP);
+ ParserKeyword staleness(Keyword::STALENESS);
ParserStringLiteral collate_locale_parser;
ParserExpressionWithOptionalAlias exp_parser(false);
@@ -2219,6 +2220,7 @@ bool ParserOrderByElement::parseImpl(Pos & pos, ASTPtr & node, Expected & expect
ASTPtr fill_from;
ASTPtr fill_to;
ASTPtr fill_step;
+ ASTPtr fill_staleness;
if (with_fill.ignore(pos, expected))
{
has_with_fill = true;
@@ -2230,6 +2232,9 @@ bool ParserOrderByElement::parseImpl(Pos & pos, ASTPtr & node, Expected & expect
if (step.ignore(pos, expected) && !exp_parser.parse(pos, fill_step, expected))
return false;
+
+ if (staleness.ignore(pos, expected) && !exp_parser.parse(pos, fill_staleness, expected))
+ return false;
}
auto elem = std::make_shared();
@@ -2244,6 +2249,7 @@ bool ParserOrderByElement::parseImpl(Pos & pos, ASTPtr & node, Expected & expect
elem->setFillFrom(fill_from);
elem->setFillTo(fill_to);
elem->setFillStep(fill_step);
+ elem->setFillStaleness(fill_staleness);
node = elem;
diff --git a/src/Planner/CollectColumnIdentifiers.cpp b/src/Planner/CollectColumnIdentifiers.cpp
index dd5bdd4d141..95f1c7d53d8 100644
--- a/src/Planner/CollectColumnIdentifiers.cpp
+++ b/src/Planner/CollectColumnIdentifiers.cpp
@@ -2,7 +2,6 @@
#include
#include
-#include
#include
diff --git a/src/Planner/PlannerActionsVisitor.cpp b/src/Planner/PlannerActionsVisitor.cpp
index aea304e0ecc..aa233109fa9 100644
--- a/src/Planner/PlannerActionsVisitor.cpp
+++ b/src/Planner/PlannerActionsVisitor.cpp
@@ -391,6 +391,9 @@ public:
if (sort_node.hasFillStep())
buffer << " STEP " << calculateActionNodeName(sort_node.getFillStep());
+
+ if (sort_node.hasFillStaleness())
+ buffer << " STALENESS " << calculateActionNodeName(sort_node.getFillStaleness());
}
if (i + 1 != order_by_nodes_size)
diff --git a/src/Planner/PlannerJoinTree.cpp b/src/Planner/PlannerJoinTree.cpp
index fb36484c02e..03eb4d82cc7 100644
--- a/src/Planner/PlannerJoinTree.cpp
+++ b/src/Planner/PlannerJoinTree.cpp
@@ -104,7 +104,6 @@ namespace Setting
extern const SettingsBool optimize_move_to_prewhere;
extern const SettingsBool optimize_move_to_prewhere_if_final;
extern const SettingsBool use_concurrency_control;
- extern const SettingsJoinInnerTableSelectionMode query_plan_join_inner_table_selection;
}
namespace ErrorCodes
@@ -1268,55 +1267,6 @@ void joinCastPlanColumnsToNullable(QueryPlan & plan_to_add_cast, PlannerContextP
plan_to_add_cast.addStep(std::move(cast_join_columns_step));
}
-std::optional createStepToDropColumns(
- const Block & header,
- const ColumnIdentifierSet & outer_scope_columns,
- const PlannerContextPtr & planner_context)
-{
- ActionsDAG drop_unused_columns_after_join_actions_dag(header.getColumnsWithTypeAndName());
- ActionsDAG::NodeRawConstPtrs drop_unused_columns_after_join_actions_dag_updated_outputs;
- std::unordered_set drop_unused_columns_after_join_actions_dag_updated_outputs_names;
- std::optional first_skipped_column_node_index;
-
- auto & drop_unused_columns_after_join_actions_dag_outputs = drop_unused_columns_after_join_actions_dag.getOutputs();
- size_t drop_unused_columns_after_join_actions_dag_outputs_size = drop_unused_columns_after_join_actions_dag_outputs.size();
-
- const auto & global_planner_context = planner_context->getGlobalPlannerContext();
-
- for (size_t i = 0; i < drop_unused_columns_after_join_actions_dag_outputs_size; ++i)
- {
- const auto & output = drop_unused_columns_after_join_actions_dag_outputs[i];
-
- if (drop_unused_columns_after_join_actions_dag_updated_outputs_names.contains(output->result_name)
- || !global_planner_context->hasColumnIdentifier(output->result_name))
- continue;
-
- if (!outer_scope_columns.contains(output->result_name))
- {
- if (!first_skipped_column_node_index)
- first_skipped_column_node_index = i;
- continue;
- }
-
- drop_unused_columns_after_join_actions_dag_updated_outputs.push_back(output);
- drop_unused_columns_after_join_actions_dag_updated_outputs_names.insert(output->result_name);
- }
-
- if (!first_skipped_column_node_index)
- return {};
-
- /** It is expected that JOIN TREE query plan will contain at least 1 column, even if there are no columns in outer scope.
- *
- * Example: SELECT count() FROM test_table_1 AS t1, test_table_2 AS t2;
- */
- if (drop_unused_columns_after_join_actions_dag_updated_outputs.empty() && first_skipped_column_node_index)
- drop_unused_columns_after_join_actions_dag_updated_outputs.push_back(drop_unused_columns_after_join_actions_dag_outputs[*first_skipped_column_node_index]);
-
- drop_unused_columns_after_join_actions_dag_outputs = std::move(drop_unused_columns_after_join_actions_dag_updated_outputs);
-
- return drop_unused_columns_after_join_actions_dag;
-}
-
JoinTreeQueryPlan buildQueryPlanForJoinNode(const QueryTreeNodePtr & join_table_expression,
JoinTreeQueryPlan left_join_tree_query_plan,
JoinTreeQueryPlan right_join_tree_query_plan,
@@ -1589,37 +1539,21 @@ JoinTreeQueryPlan buildQueryPlanForJoinNode(const QueryTreeNodePtr & join_table_
}
const Block & left_header = left_plan.getCurrentHeader();
+ auto left_table_names = left_header.getNames();
+ NameSet left_table_names_set(left_table_names.begin(), left_table_names.end());
+
+ auto columns_from_joined_table = right_plan.getCurrentHeader().getNamesAndTypesList();
+ table_join->setColumnsFromJoinedTable(columns_from_joined_table, left_table_names_set, "");
+
+ for (auto & column_from_joined_table : columns_from_joined_table)
+ {
+ /// Add columns from joined table only if they are presented in outer scope, otherwise they can be dropped
+ if (planner_context->getGlobalPlannerContext()->hasColumnIdentifier(column_from_joined_table.name) &&
+ outer_scope_columns.contains(column_from_joined_table.name))
+ table_join->addJoinedColumn(column_from_joined_table);
+ }
+
const Block & right_header = right_plan.getCurrentHeader();
-
- auto columns_from_left_table = left_header.getNamesAndTypesList();
- auto columns_from_right_table = right_header.getNamesAndTypesList();
-
- table_join->setInputColumns(columns_from_left_table, columns_from_right_table);
-
- for (auto & column_from_joined_table : columns_from_left_table)
- {
- /// Add columns to output only if they are presented in outer scope, otherwise they can be dropped
- if (planner_context->getGlobalPlannerContext()->hasColumnIdentifier(column_from_joined_table.name) &&
- outer_scope_columns.contains(column_from_joined_table.name))
- table_join->setUsedColumn(column_from_joined_table, JoinTableSide::Left);
- }
-
- for (auto & column_from_joined_table : columns_from_right_table)
- {
- /// Add columns to output only if they are presented in outer scope, otherwise they can be dropped
- if (planner_context->getGlobalPlannerContext()->hasColumnIdentifier(column_from_joined_table.name) &&
- outer_scope_columns.contains(column_from_joined_table.name))
- table_join->setUsedColumn(column_from_joined_table, JoinTableSide::Right);
- }
-
- if (table_join->getOutputColumns(JoinTableSide::Left).empty() && table_join->getOutputColumns(JoinTableSide::Right).empty())
- {
- if (!columns_from_left_table.empty())
- table_join->setUsedColumn(columns_from_left_table.front(), JoinTableSide::Left);
- else if (!columns_from_right_table.empty())
- table_join->setUsedColumn(columns_from_right_table.front(), JoinTableSide::Right);
- }
-
auto join_algorithm = chooseJoinAlgorithm(table_join, join_node.getRightTableExpression(), left_header, right_header, planner_context);
auto result_plan = QueryPlan();
@@ -1707,26 +1641,13 @@ JoinTreeQueryPlan buildQueryPlanForJoinNode(const QueryTreeNodePtr & join_table_
}
auto join_pipeline_type = join_algorithm->pipelineType();
-
- ColumnIdentifierSet outer_scope_columns_nonempty;
- if (outer_scope_columns.empty())
- {
- if (left_header.columns() > 1)
- outer_scope_columns_nonempty.insert(left_header.getByPosition(0).name);
- else if (right_header.columns() > 1)
- outer_scope_columns_nonempty.insert(right_header.getByPosition(0).name);
- }
-
auto join_step = std::make_unique(
left_plan.getCurrentHeader(),
right_plan.getCurrentHeader(),
std::move(join_algorithm),
settings[Setting::max_block_size],
settings[Setting::max_threads],
- outer_scope_columns.empty() ? outer_scope_columns_nonempty : outer_scope_columns,
- false /*optimize_read_in_order*/,
- true /*optimize_skip_unused_shards*/);
- join_step->inner_table_selection_mode = settings[Setting::query_plan_join_inner_table_selection];
+ false /*optimize_read_in_order*/);
join_step->setStepDescription(fmt::format("JOIN {}", join_pipeline_type));
@@ -1737,18 +1658,47 @@ JoinTreeQueryPlan buildQueryPlanForJoinNode(const QueryTreeNodePtr & join_table_
result_plan.unitePlans(std::move(join_step), {std::move(plans)});
}
- const auto & header_after_join = result_plan.getCurrentHeader();
- if (header_after_join.columns() > outer_scope_columns.size())
+ ActionsDAG drop_unused_columns_after_join_actions_dag(result_plan.getCurrentHeader().getColumnsWithTypeAndName());
+ ActionsDAG::NodeRawConstPtrs drop_unused_columns_after_join_actions_dag_updated_outputs;
+ std::unordered_set drop_unused_columns_after_join_actions_dag_updated_outputs_names;
+ std::optional first_skipped_column_node_index;
+
+ auto & drop_unused_columns_after_join_actions_dag_outputs = drop_unused_columns_after_join_actions_dag.getOutputs();
+ size_t drop_unused_columns_after_join_actions_dag_outputs_size = drop_unused_columns_after_join_actions_dag_outputs.size();
+
+ for (size_t i = 0; i < drop_unused_columns_after_join_actions_dag_outputs_size; ++i)
{
- auto drop_unused_columns_after_join_actions_dag = createStepToDropColumns(header_after_join, outer_scope_columns, planner_context);
- if (drop_unused_columns_after_join_actions_dag)
+ const auto & output = drop_unused_columns_after_join_actions_dag_outputs[i];
+
+ const auto & global_planner_context = planner_context->getGlobalPlannerContext();
+ if (drop_unused_columns_after_join_actions_dag_updated_outputs_names.contains(output->result_name)
+ || !global_planner_context->hasColumnIdentifier(output->result_name))
+ continue;
+
+ if (!outer_scope_columns.contains(output->result_name))
{
- auto drop_unused_columns_after_join_transform_step = std::make_unique(result_plan.getCurrentHeader(), std::move(*drop_unused_columns_after_join_actions_dag));
- drop_unused_columns_after_join_transform_step->setStepDescription("Drop unused columns after JOIN");
- result_plan.addStep(std::move(drop_unused_columns_after_join_transform_step));
+ if (!first_skipped_column_node_index)
+ first_skipped_column_node_index = i;
+ continue;
}
+
+ drop_unused_columns_after_join_actions_dag_updated_outputs.push_back(output);
+ drop_unused_columns_after_join_actions_dag_updated_outputs_names.insert(output->result_name);
}
+ /** It is expected that JOIN TREE query plan will contain at least 1 column, even if there are no columns in outer scope.
+ *
+ * Example: SELECT count() FROM test_table_1 AS t1, test_table_2 AS t2;
+ */
+ if (drop_unused_columns_after_join_actions_dag_updated_outputs.empty() && first_skipped_column_node_index)
+ drop_unused_columns_after_join_actions_dag_updated_outputs.push_back(drop_unused_columns_after_join_actions_dag_outputs[*first_skipped_column_node_index]);
+
+ drop_unused_columns_after_join_actions_dag_outputs = std::move(drop_unused_columns_after_join_actions_dag_updated_outputs);
+
+ auto drop_unused_columns_after_join_transform_step = std::make_unique(result_plan.getCurrentHeader(), std::move(drop_unused_columns_after_join_actions_dag));
+ drop_unused_columns_after_join_transform_step->setStepDescription("DROP unused columns after JOIN");
+ result_plan.addStep(std::move(drop_unused_columns_after_join_transform_step));
+
for (const auto & right_join_tree_query_plan_row_policy : right_join_tree_query_plan.used_row_policies)
left_join_tree_query_plan.used_row_policies.insert(right_join_tree_query_plan_row_policy);
diff --git a/src/Planner/PlannerSorting.cpp b/src/Planner/PlannerSorting.cpp
index af51afdef13..9476ae348c5 100644
--- a/src/Planner/PlannerSorting.cpp
+++ b/src/Planner/PlannerSorting.cpp
@@ -43,7 +43,7 @@ std::pair extractWithFillValue(const QueryTreeNodePtr & node
return result;
}
-std::pair> extractWithFillStepValue(const QueryTreeNodePtr & node)
+std::pair> extractWithFillValueWithIntervalKind(const QueryTreeNodePtr & node)
{
const auto & constant_node = node->as();
@@ -77,7 +77,7 @@ FillColumnDescription extractWithFillDescription(const SortNode & sort_node)
if (sort_node.hasFillStep())
{
- auto extract_result = extractWithFillStepValue(sort_node.getFillStep());
+ auto extract_result = extractWithFillValueWithIntervalKind(sort_node.getFillStep());
fill_column_description.fill_step = std::move(extract_result.first);
fill_column_description.step_kind = std::move(extract_result.second);
}
@@ -87,16 +87,36 @@ FillColumnDescription extractWithFillDescription(const SortNode & sort_node)
fill_column_description.fill_step = Field(direction_value);
}
+ if (sort_node.getFillStaleness())
+ {
+ auto extract_result = extractWithFillValueWithIntervalKind(sort_node.getFillStaleness());
+ fill_column_description.fill_staleness = std::move(extract_result.first);
+ fill_column_description.staleness_kind = std::move(extract_result.second);
+ }
+
+ ///////////////////////////////////
+
if (applyVisitor(FieldVisitorAccurateEquals(), fill_column_description.fill_step, Field{0}))
throw Exception(ErrorCodes::INVALID_WITH_FILL_EXPRESSION,
"WITH FILL STEP value cannot be zero");
+ if (sort_node.hasFillStaleness())
+ {
+ if (sort_node.hasFillFrom())
+ throw Exception(ErrorCodes::INVALID_WITH_FILL_EXPRESSION,
+ "WITH FILL STALENESS cannot be used together with WITH FILL FROM");
+ }
+
if (sort_node.getSortDirection() == SortDirection::ASCENDING)
{
if (applyVisitor(FieldVisitorAccurateLess(), fill_column_description.fill_step, Field{0}))
throw Exception(ErrorCodes::INVALID_WITH_FILL_EXPRESSION,
"WITH FILL STEP value cannot be negative for sorting in ascending direction");
+ if (applyVisitor(FieldVisitorAccurateLess(), fill_column_description.fill_staleness, Field{0}))
+ throw Exception(ErrorCodes::INVALID_WITH_FILL_EXPRESSION,
+ "WITH FILL STALENESS value cannot be negative for sorting in ascending direction");
+
if (!fill_column_description.fill_from.isNull() && !fill_column_description.fill_to.isNull() &&
applyVisitor(FieldVisitorAccurateLess(), fill_column_description.fill_to, fill_column_description.fill_from))
{
@@ -110,6 +130,10 @@ FillColumnDescription extractWithFillDescription(const SortNode & sort_node)
throw Exception(ErrorCodes::INVALID_WITH_FILL_EXPRESSION,
"WITH FILL STEP value cannot be positive for sorting in descending direction");
+ if (applyVisitor(FieldVisitorAccurateLess(), Field{0}, fill_column_description.fill_staleness))
+ throw Exception(ErrorCodes::INVALID_WITH_FILL_EXPRESSION,
+ "WITH FILL STALENESS value cannot be positive for sorting in descending direction");
+
if (!fill_column_description.fill_from.isNull() && !fill_column_description.fill_to.isNull() &&
applyVisitor(FieldVisitorAccurateLess(), fill_column_description.fill_from, fill_column_description.fill_to))
{
diff --git a/src/Processors/Merges/Algorithms/IMergingAlgorithmWithDelayedChunk.cpp b/src/Processors/Merges/Algorithms/IMergingAlgorithmWithDelayedChunk.cpp
index cbad6813fbc..5e271e12943 100644
--- a/src/Processors/Merges/Algorithms/IMergingAlgorithmWithDelayedChunk.cpp
+++ b/src/Processors/Merges/Algorithms/IMergingAlgorithmWithDelayedChunk.cpp
@@ -24,7 +24,12 @@ void IMergingAlgorithmWithDelayedChunk::initializeQueue(Inputs inputs)
continue;
cursors[source_num] = SortCursorImpl(
- header, current_inputs[source_num].chunk.getColumns(), description, source_num, current_inputs[source_num].permutation);
+ header,
+ current_inputs[source_num].chunk.getColumns(),
+ current_inputs[source_num].chunk.getNumRows(),
+ description,
+ source_num,
+ current_inputs[source_num].permutation);
inputs_origin_merge_tree_part_level[source_num] = getPartLevelFromChunk(current_inputs[source_num].chunk);
}
@@ -41,7 +46,7 @@ void IMergingAlgorithmWithDelayedChunk::updateCursor(Input & input, size_t sourc
last_chunk_sort_columns = std::move(cursors[source_num].sort_columns);
current_input.swap(input);
- cursors[source_num].reset(current_input.chunk.getColumns(), header, current_input.permutation);
+ cursors[source_num].reset(current_input.chunk.getColumns(), header, current_input.chunk.getNumRows(), current_input.permutation);
inputs_origin_merge_tree_part_level[source_num] = getPartLevelFromChunk(current_input.chunk);
diff --git a/src/Processors/Merges/Algorithms/IMergingAlgorithmWithSharedChunks.cpp b/src/Processors/Merges/Algorithms/IMergingAlgorithmWithSharedChunks.cpp
index 47b7ddf38dc..f99f021286e 100644
--- a/src/Processors/Merges/Algorithms/IMergingAlgorithmWithSharedChunks.cpp
+++ b/src/Processors/Merges/Algorithms/IMergingAlgorithmWithSharedChunks.cpp
@@ -31,7 +31,8 @@ void IMergingAlgorithmWithSharedChunks::initialize(Inputs inputs)
source.skip_last_row = inputs[source_num].skip_last_row;
source.chunk = chunk_allocator.alloc(inputs[source_num].chunk);
- cursors[source_num] = SortCursorImpl(header, source.chunk->getColumns(), description, source_num, inputs[source_num].permutation);
+ cursors[source_num] = SortCursorImpl(
+ header, source.chunk->getColumns(), source.chunk->getNumRows(), description, source_num, inputs[source_num].permutation);
source.chunk->all_columns = cursors[source_num].all_columns;
source.chunk->sort_columns = cursors[source_num].sort_columns;
@@ -49,7 +50,7 @@ void IMergingAlgorithmWithSharedChunks::consume(Input & input, size_t source_num
auto & source = sources[source_num];
source.skip_last_row = input.skip_last_row;
source.chunk = chunk_allocator.alloc(input.chunk);
- cursors[source_num].reset(source.chunk->getColumns(), header, input.permutation);
+ cursors[source_num].reset(source.chunk->getColumns(), header, source.chunk->getNumRows(), input.permutation);
source.chunk->all_columns = cursors[source_num].all_columns;
source.chunk->sort_columns = cursors[source_num].sort_columns;
diff --git a/src/Processors/Merges/Algorithms/MergingSortedAlgorithm.cpp b/src/Processors/Merges/Algorithms/MergingSortedAlgorithm.cpp
index 3a9cf7ee141..28c6cb473e5 100644
--- a/src/Processors/Merges/Algorithms/MergingSortedAlgorithm.cpp
+++ b/src/Processors/Merges/Algorithms/MergingSortedAlgorithm.cpp
@@ -59,7 +59,7 @@ void MergingSortedAlgorithm::initialize(Inputs inputs)
if (!chunk)
continue;
- cursors[source_num] = SortCursorImpl(header, chunk.getColumns(), description, source_num);
+ cursors[source_num] = SortCursorImpl(header, chunk.getColumns(), chunk.getNumRows(), description, source_num);
}
if (sorting_queue_strategy == SortingQueueStrategy::Default)
@@ -84,7 +84,7 @@ void MergingSortedAlgorithm::consume(Input & input, size_t source_num)
{
removeConstAndSparse(input);
current_inputs[source_num].swap(input);
- cursors[source_num].reset(current_inputs[source_num].chunk.getColumns(), header);
+ cursors[source_num].reset(current_inputs[source_num].chunk.getColumns(), header, current_inputs[source_num].chunk.getNumRows());
if (sorting_queue_strategy == SortingQueueStrategy::Default)
{
diff --git a/src/Processors/QueryPlan/JoinStep.cpp b/src/Processors/QueryPlan/JoinStep.cpp
index 7ade437822e..018b52a5c68 100644
--- a/src/Processors/QueryPlan/JoinStep.cpp
+++ b/src/Processors/QueryPlan/JoinStep.cpp
@@ -6,7 +6,6 @@
#include
#include
#include
-#include
namespace DB
{
@@ -37,37 +36,6 @@ std::vector> describeJoinActions(const JoinPtr & join)
return description;
}
-std::vector getPermutationForBlock(
- const Block & block,
- const Block & lhs_block,
- const Block & rhs_block,
- const NameSet & name_filter)
-{
- std::vector permutation;
- permutation.reserve(block.columns());
- Block::NameMap name_map = block.getNamesToIndexesMap();
-
- bool is_trivial = true;
- for (const auto & other_block : {lhs_block, rhs_block})
- {
- for (const auto & col : other_block)
- {
- if (!name_filter.contains(col.name))
- continue;
- if (auto it = name_map.find(col.name); it != name_map.end())
- {
- is_trivial = is_trivial && it->second == permutation.size();
- permutation.push_back(it->second);
- }
- }
- }
-
- if (is_trivial && permutation.size() == block.columns())
- return {};
-
- return permutation;
-}
-
}
JoinStep::JoinStep(
@@ -76,15 +44,8 @@ JoinStep::JoinStep(
JoinPtr join_,
size_t max_block_size_,
size_t max_streams_,
- NameSet required_output_,
- bool keep_left_read_in_order_,
- bool use_new_analyzer_)
- : join(std::move(join_))
- , max_block_size(max_block_size_)
- , max_streams(max_streams_)
- , required_output(std::move(required_output_))
- , keep_left_read_in_order(keep_left_read_in_order_)
- , use_new_analyzer(use_new_analyzer_)
+ bool keep_left_read_in_order_)
+ : join(std::move(join_)), max_block_size(max_block_size_), max_streams(max_streams_), keep_left_read_in_order(keep_left_read_in_order_)
{
updateInputHeaders({left_header_, right_header_});
}
@@ -94,43 +55,23 @@ QueryPipelineBuilderPtr JoinStep::updatePipeline(QueryPipelineBuilders pipelines
if (pipelines.size() != 2)
throw Exception(ErrorCodes::LOGICAL_ERROR, "JoinStep expect two input steps");
- Block lhs_header = pipelines[0]->getHeader();
- Block rhs_header = pipelines[1]->getHeader();
-
- if (swap_streams)
- std::swap(pipelines[0], pipelines[1]);
-
if (join->pipelineType() == JoinPipelineType::YShaped)
{
auto joined_pipeline = QueryPipelineBuilder::joinPipelinesYShaped(
- std::move(pipelines[0]), std::move(pipelines[1]), join, join_algorithm_header, max_block_size, &processors);
+ std::move(pipelines[0]), std::move(pipelines[1]), join, *output_header, max_block_size, &processors);
joined_pipeline->resize(max_streams);
return joined_pipeline;
}
- auto pipeline = QueryPipelineBuilder::joinPipelinesRightLeft(
+ return QueryPipelineBuilder::joinPipelinesRightLeft(
std::move(pipelines[0]),
std::move(pipelines[1]),
join,
- join_algorithm_header,
+ *output_header,
max_block_size,
max_streams,
keep_left_read_in_order,
&processors);
-
- if (!use_new_analyzer)
- return pipeline;
-
- auto column_permutation = getPermutationForBlock(pipeline->getHeader(), lhs_header, rhs_header, required_output);
- if (!column_permutation.empty())
- {
- pipeline->addSimpleTransform([&column_permutation](const Block & header)
- {
- return std::make_shared(header, column_permutation);
- });
- }
-
- return pipeline;
}
bool JoinStep::allowPushDownToRight() const
@@ -149,49 +90,17 @@ void JoinStep::describeActions(FormatSettings & settings) const
for (const auto & [name, value] : describeJoinActions(join))
settings.out << prefix << name << ": " << value << '\n';
- if (swap_streams)
- settings.out << prefix << "Swapped: true\n";
}
void JoinStep::describeActions(JSONBuilder::JSONMap & map) const
{
for (const auto & [name, value] : describeJoinActions(join))
map.add(name, value);
- if (swap_streams)
- map.add("Swapped", true);
-}
-
-void JoinStep::setJoin(JoinPtr join_, bool swap_streams_)
-{
- join_algorithm_header.clear();
- swap_streams = swap_streams_;
- join = std::move(join_);
- updateOutputHeader();
}
void JoinStep::updateOutputHeader()
{
- if (join_algorithm_header)
- return;
-
- const auto & header = swap_streams ? input_headers[1] : input_headers[0];
-
- Block result_header = JoiningTransform::transformHeader(header, join);
- join_algorithm_header = result_header;
-
- if (!use_new_analyzer)
- {
- if (swap_streams)
- throw Exception(ErrorCodes::LOGICAL_ERROR, "Cannot swap streams without new analyzer");
- output_header = result_header;
- return;
- }
-
- auto column_permutation = getPermutationForBlock(result_header, input_headers[0], input_headers[1], required_output);
- if (!column_permutation.empty())
- result_header = ColumnPermuteTransform::permute(result_header, column_permutation);
-
- output_header = result_header;
+ output_header = JoiningTransform::transformHeader(input_headers.front(), join);
}
static ITransformingStep::Traits getStorageJoinTraits()
diff --git a/src/Processors/QueryPlan/JoinStep.h b/src/Processors/QueryPlan/JoinStep.h
index 1eca42c62cf..2793784d633 100644
--- a/src/Processors/QueryPlan/JoinStep.h
+++ b/src/Processors/QueryPlan/JoinStep.h
@@ -2,7 +2,6 @@
#include
#include
-#include
namespace DB
{
@@ -20,9 +19,7 @@ public:
JoinPtr join_,
size_t max_block_size_,
size_t max_streams_,
- NameSet required_output_,
- bool keep_left_read_in_order_,
- bool use_new_analyzer_);
+ bool keep_left_read_in_order_);
String getName() const override { return "Join"; }
@@ -34,26 +31,16 @@ public:
void describeActions(FormatSettings & settings) const override;
const JoinPtr & getJoin() const { return join; }
- void setJoin(JoinPtr join_, bool swap_streams_ = false);
+ void setJoin(JoinPtr join_) { join = std::move(join_); }
bool allowPushDownToRight() const;
- JoinInnerTableSelectionMode inner_table_selection_mode = JoinInnerTableSelectionMode::Right;
-
private:
void updateOutputHeader() override;
- /// Header that expected to be returned from IJoin
- Block join_algorithm_header;
-
JoinPtr join;
size_t max_block_size;
size_t max_streams;
-
- const NameSet required_output;
- std::set columns_to_remove;
bool keep_left_read_in_order;
- bool use_new_analyzer = false;
- bool swap_streams = false;
};
/// Special step for the case when Join is already filled.
diff --git a/src/Processors/QueryPlan/Optimizations/Optimizations.h b/src/Processors/QueryPlan/Optimizations/Optimizations.h
index c1c4d1e1635..751d5182dc3 100644
--- a/src/Processors/QueryPlan/Optimizations/Optimizations.h
+++ b/src/Processors/QueryPlan/Optimizations/Optimizations.h
@@ -113,7 +113,6 @@ void optimizePrimaryKeyConditionAndLimit(const Stack & stack);
void optimizePrewhere(Stack & stack, QueryPlan::Nodes & nodes);
void optimizeReadInOrder(QueryPlan::Node & node, QueryPlan::Nodes & nodes);
void optimizeAggregationInOrder(QueryPlan::Node & node, QueryPlan::Nodes &);
-void optimizeJoin(QueryPlan::Node & node, QueryPlan::Nodes &);
void optimizeDistinctInOrder(QueryPlan::Node & node, QueryPlan::Nodes &);
/// A separate tree traverse to apply sorting properties after *InOrder optimizations.
diff --git a/src/Processors/QueryPlan/Optimizations/optimizeJoin.cpp b/src/Processors/QueryPlan/Optimizations/optimizeJoin.cpp
deleted file mode 100644
index 35d340b4bbf..00000000000
--- a/src/Processors/QueryPlan/Optimizations/optimizeJoin.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-
-#include
-#include
-
-namespace DB::QueryPlanOptimizations
-{
-
-static std::optional estimateReadRowsCount(QueryPlan::Node & node)
-{
- IQueryPlanStep * step = node.step.get();
- if (const auto * reading = typeid_cast(step))
- {
- if (auto analyzed_result = reading->getAnalyzedResult())
- return analyzed_result->selected_rows;
- if (auto analyzed_result = reading->selectRangesToRead())
- return analyzed_result->selected_rows;
- return {};
- }
-
- if (const auto * reading = typeid_cast(step))
- return reading->getStorage()->totalRows(Settings{});
-
- if (node.children.size() != 1)
- return {};
-
- if (typeid_cast(step) || typeid_cast(step))
- return estimateReadRowsCount(*node.children.front());
-
- return {};
-}
-
-void optimizeJoin(QueryPlan::Node & node, QueryPlan::Nodes &)
-{
- auto * join_step = typeid_cast(node.step.get());
- if (!join_step || node.children.size() != 2)
- return;
-
- const auto & join = join_step->getJoin();
- if (join->pipelineType() != JoinPipelineType::FillRightFirst || !join->isCloneSupported())
- return;
-
- const auto & table_join = join->getTableJoin();
-
- /// Algorithms other than HashJoin may not support OUTER JOINs
- if (table_join.kind() != JoinKind::Inner && !typeid_cast(join.get()))
- return;
-
- /// fixme: USING clause handled specially in join algorithm, so swap breaks it
- /// fixme: Swapping for SEMI and ANTI joins should be alright, need to try to enable it and test
- if (table_join.hasUsing() || table_join.strictness() != JoinStrictness::All)
- return;
-
- bool need_swap = false;
- if (join_step->inner_table_selection_mode == JoinInnerTableSelectionMode::Auto)
- {
- auto lhs_extimation = estimateReadRowsCount(*node.children[0]);
- auto rhs_extimation = estimateReadRowsCount(*node.children[1]);
- LOG_TRACE(getLogger("optimizeJoin"), "Left table estimation: {}, right table estimation: {}",
- lhs_extimation.transform(toString).value_or("unknown"),
- rhs_extimation.transform(toString).value_or("unknown"));
-
- if (lhs_extimation && rhs_extimation && *lhs_extimation < *rhs_extimation)
- need_swap = true;
- }
- else if (join_step->inner_table_selection_mode == JoinInnerTableSelectionMode::Left)
- {
- need_swap = true;
- }
-
- if (!need_swap)
- return;
-
- const auto & headers = join_step->getInputHeaders();
- if (headers.size() != 2)
- return;
-
- const auto & left_stream_input_header = headers.front();
- const auto & right_stream_input_header = headers.back();
-
- auto updated_table_join = std::make_shared(table_join);
- updated_table_join->swapSides();
- auto updated_join = join->clone(updated_table_join, right_stream_input_header, left_stream_input_header);
- join_step->setJoin(std::move(updated_join), /* swap_streams= */ true);
-}
-
-}
diff --git a/src/Processors/QueryPlan/Optimizations/optimizeTree.cpp b/src/Processors/QueryPlan/Optimizations/optimizeTree.cpp
index c034ca79181..03418c752d4 100644
--- a/src/Processors/QueryPlan/Optimizations/optimizeTree.cpp
+++ b/src/Processors/QueryPlan/Optimizations/optimizeTree.cpp
@@ -227,9 +227,6 @@ void addStepsToBuildSets(QueryPlan & plan, QueryPlan::Node & root, QueryPlan::No
/// NOTE: frame cannot be safely used after stack was modified.
auto & frame = stack.back();
- if (frame.next_child == 0)
- optimizeJoin(*frame.node, nodes);
-
/// Traverse all children first.
if (frame.next_child < frame.node->children.size())
{
diff --git a/src/Processors/QueryPlan/ReadFromMemoryStorageStep.h b/src/Processors/QueryPlan/ReadFromMemoryStorageStep.h
index a9c2d2df2c4..238c1a3aad0 100644
--- a/src/Processors/QueryPlan/ReadFromMemoryStorageStep.h
+++ b/src/Processors/QueryPlan/ReadFromMemoryStorageStep.h
@@ -35,8 +35,6 @@ public:
void initializePipeline(QueryPipelineBuilder & pipeline, const BuildQueryPipelineSettings &) override;
- const StoragePtr & getStorage() const { return storage; }
-
private:
static constexpr auto name = "ReadFromMemoryStorage";
diff --git a/src/Processors/Transforms/ColumnPermuteTransform.cpp b/src/Processors/Transforms/ColumnPermuteTransform.cpp
deleted file mode 100644
index f371689814c..00000000000
--- a/src/Processors/Transforms/ColumnPermuteTransform.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-#include
-
-namespace DB
-{
-
-namespace
-{
-
-template
-void applyPermutation(std::vector & data, const std::vector & permutation)
-{
- std::vector res;
- res.reserve(permutation.size());
- for (size_t i : permutation)
- res.push_back(data[i]);
- data = std::move(res);
-}
-
-void permuteChunk(Chunk & chunk, const std::vector & permutation)
-{
- size_t num_rows = chunk.getNumRows();
- auto columns = chunk.detachColumns();
- applyPermutation(columns, permutation);
- chunk.setColumns(std::move(columns), num_rows);
-}
-
-}
-
-Block ColumnPermuteTransform::permute(const Block & block, const std::vector & permutation)
-{
- auto columns = block.getColumnsWithTypeAndName();
- applyPermutation(columns, permutation);
- return Block(columns);
-}
-
-ColumnPermuteTransform::ColumnPermuteTransform(const Block & header_, const std::vector & permutation_)
- : ISimpleTransform(header_, permute(header_, permutation_), false)
- , permutation(permutation_)
-{
-}
-
-
-void ColumnPermuteTransform::transform(Chunk & chunk)
-{
- permuteChunk(chunk, permutation);
-}
-
-
-}
diff --git a/src/Processors/Transforms/ColumnPermuteTransform.h b/src/Processors/Transforms/ColumnPermuteTransform.h
deleted file mode 100644
index 25f3a8d0825..00000000000
--- a/src/Processors/Transforms/ColumnPermuteTransform.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#pragma once
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-namespace DB
-{
-
-class ColumnPermuteTransform : public ISimpleTransform
-{
-public:
- ColumnPermuteTransform(const Block & header_, const std::vector & permutation_);
-
- String getName() const override { return "ColumnPermuteTransform"; }
-
- void transform(Chunk & chunk) override;
-
- static Block permute(const Block & block, const std::vector & permutation);
-
-private:
- Names column_names;
- std::vector permutation;
-};
-
-
-}
diff --git a/src/Processors/Transforms/FillingTransform.cpp b/src/Processors/Transforms/FillingTransform.cpp
index 95f4a674ebb..ab782f3e521 100644
--- a/src/Processors/Transforms/FillingTransform.cpp
+++ b/src/Processors/Transforms/FillingTransform.cpp
@@ -7,18 +7,20 @@
#include
#include
#include
+#include
#include
#include
#include
+#include
namespace DB
{
-constexpr bool debug_logging_enabled = false;
+constexpr static bool debug_logging_enabled = false;
template
-void logDebug(String key, const T & value, const char * separator = " : ")
+inline static void logDebug(const char * key, const T & value, const char * separator = " : ")
{
if constexpr (debug_logging_enabled)
{
@@ -60,15 +62,74 @@ static FillColumnDescription::StepFunction getStepFunction(
{
#define DECLARE_CASE(NAME) \
case IntervalKind::Kind::NAME: \
- return [step, scale, &date_lut](Field & field) { \
+ return [step, scale, &date_lut](Field & field, Int32 jumps_count) { \
field = Add##NAME##sImpl::execute(static_cast(\
- field.safeGet()), static_cast(step), date_lut, utc_time_zone, scale); };
+ field.safeGet()), static_cast(step) * jumps_count, date_lut, utc_time_zone, scale); };
FOR_EACH_INTERVAL_KIND(DECLARE_CASE)
#undef DECLARE_CASE
}
}
+static FillColumnDescription::StepFunction getStepFunction(const Field & step, const std::optional & step_kind, const DataTypePtr & type)
+{
+ WhichDataType which(type);
+
+ if (step_kind)
+ {
+ if (which.isDate() || which.isDate32())
+ {
+ Int64 avg_seconds = step.safeGet() * step_kind->toAvgSeconds();
+ if (std::abs(avg_seconds) < 86400)
+ throw Exception(ErrorCodes::INVALID_WITH_FILL_EXPRESSION,
+ "Value of step is to low ({} seconds). Must be >= 1 day", std::abs(avg_seconds));
+ }
+
+ if (which.isDate())
+ return getStepFunction(step_kind.value(), step.safeGet(), DateLUT::instance());
+ else if (which.isDate32())
+ return getStepFunction(step_kind.value(), step.safeGet(), DateLUT::instance());
+ else if (const auto * date_time = checkAndGetDataType(type.get()))
+ return getStepFunction(step_kind.value(), step.safeGet(), date_time->getTimeZone());
+ else if (const auto * date_time64 = checkAndGetDataType(type.get()))
+ {
+ const auto & step_dec = step.safeGet &>();
+ Int64 converted_step = DecimalUtils::convertTo(step_dec.getValue(), step_dec.getScale());
+ static const DateLUTImpl & utc_time_zone = DateLUT::instance("UTC");
+
+ switch (step_kind.value()) // NOLINT(bugprone-switch-missing-default-case)
+ {
+#define DECLARE_CASE(NAME) \
+ case IntervalKind::Kind::NAME: \
+ return [converted_step, &time_zone = date_time64->getTimeZone()](Field & field, Int32 jumps_count) \
+ { \
+ auto field_decimal = field.safeGet>(); \
+ auto res = Add##NAME##sImpl::execute(field_decimal.getValue(), converted_step * jumps_count, time_zone, utc_time_zone, field_decimal.getScale()); \
+ field = DecimalField(res, field_decimal.getScale()); \
+ }; \
+ break;
+
+ FOR_EACH_INTERVAL_KIND(DECLARE_CASE)
+#undef DECLARE_CASE
+ }
+ }
+ else
+ throw Exception(ErrorCodes::INVALID_WITH_FILL_EXPRESSION,
+ "STEP of Interval type can be used only with Date/DateTime types, but got {}", type->getName());
+ }
+ else
+ {
+ return [step](Field & field, Int32 jumps_count)
+ {
+ auto shifted_step = step;
+ if (jumps_count != 1)
+ applyVisitor(FieldVisitorScale(jumps_count), shifted_step);
+
+ applyVisitor(FieldVisitorSum(shifted_step), field);
+ };
+ }
+}
+
static bool tryConvertFields(FillColumnDescription & descr, const DataTypePtr & type)
{
auto max_type = Field::Types::Null;
@@ -125,7 +186,8 @@ static bool tryConvertFields(FillColumnDescription & descr, const DataTypePtr &
if (descr.fill_from.getType() > max_type
|| descr.fill_to.getType() > max_type
- || descr.fill_step.getType() > max_type)
+ || descr.fill_step.getType() > max_type
+ || descr.fill_staleness.getType() > max_type)
return false;
if (!descr.fill_from.isNull())
@@ -134,56 +196,11 @@ static bool tryConvertFields(FillColumnDescription & descr, const DataTypePtr &
descr.fill_to = convertFieldToTypeOrThrow(descr.fill_to, *to_type);
if (!descr.fill_step.isNull())
descr.fill_step = convertFieldToTypeOrThrow(descr.fill_step, *to_type);
+ if (!descr.fill_staleness.isNull())
+ descr.fill_staleness = convertFieldToTypeOrThrow(descr.fill_staleness, *to_type);
- if (descr.step_kind)
- {
- if (which.isDate() || which.isDate32())
- {
- Int64 avg_seconds = descr.fill_step.safeGet() * descr.step_kind->toAvgSeconds();
- if (std::abs(avg_seconds) < 86400)
- throw Exception(ErrorCodes::INVALID_WITH_FILL_EXPRESSION,
- "Value of step is to low ({} seconds). Must be >= 1 day", std::abs(avg_seconds));
- }
-
- if (which.isDate())
- descr.step_func = getStepFunction(*descr.step_kind, descr.fill_step.safeGet(), DateLUT::instance());
- else if (which.isDate32())
- descr.step_func = getStepFunction(*descr.step_kind, descr.fill_step.safeGet(), DateLUT::instance());
- else if (const auto * date_time = checkAndGetDataType(type.get()))
- descr.step_func = getStepFunction(*descr.step_kind, descr.fill_step.safeGet(), date_time->getTimeZone());
- else if (const auto * date_time64 = checkAndGetDataType(type.get()))
- {
- const auto & step_dec = descr.fill_step.safeGet &>();
- Int64 step = DecimalUtils::convertTo(step_dec.getValue(), step_dec.getScale());
- static const DateLUTImpl & utc_time_zone = DateLUT::instance("UTC");
-
- switch (*descr.step_kind) // NOLINT(bugprone-switch-missing-default-case)
- {
-#define DECLARE_CASE(NAME) \
- case IntervalKind::Kind::NAME: \
- descr.step_func = [step, &time_zone = date_time64->getTimeZone()](Field & field) \
- { \
- auto field_decimal = field.safeGet>(); \
- auto res = Add##NAME##sImpl::execute(field_decimal.getValue(), step, time_zone, utc_time_zone, field_decimal.getScale()); \
- field = DecimalField(res, field_decimal.getScale()); \
- }; \
- break;
-
- FOR_EACH_INTERVAL_KIND(DECLARE_CASE)
-#undef DECLARE_CASE
- }
- }
- else
- throw Exception(ErrorCodes::INVALID_WITH_FILL_EXPRESSION,
- "STEP of Interval type can be used only with Date/DateTime types, but got {}", type->getName());
- }
- else
- {
- descr.step_func = [step = descr.fill_step](Field & field)
- {
- applyVisitor(FieldVisitorSum(step), field);
- };
- }
+ descr.step_func = getStepFunction(descr.fill_step, descr.step_kind, type);
+ descr.staleness_step_func = getStepFunction(descr.fill_staleness, descr.staleness_kind, type);
return true;
}
@@ -218,6 +235,7 @@ FillingTransform::FillingTransform(
fill_column_positions.push_back(block_position);
auto & descr = filling_row.getFillDescription(i);
+ running_with_staleness |= !descr.fill_staleness.isNull();
const Block & output_header = getOutputPort().getHeader();
const DataTypePtr & type = removeNullable(output_header.getByPosition(block_position).type);
@@ -437,7 +455,7 @@ void FillingTransform::initColumns(
non_const_columns.reserve(input_columns.size());
for (const auto & column : input_columns)
- non_const_columns.push_back(column->convertToFullColumnIfConst());
+ non_const_columns.push_back(column->convertToFullColumnIfConst()->convertToFullColumnIfSparse());
for (const auto & column : non_const_columns)
output_columns.push_back(column->cloneEmpty()->assumeMutable());
@@ -482,26 +500,26 @@ bool FillingTransform::generateSuffixIfNeeded(
MutableColumnRawPtrs res_sort_prefix_columns,
MutableColumnRawPtrs res_other_columns)
{
- logDebug("generateSuffixIfNeeded() filling_row", filling_row);
- logDebug("generateSuffixIfNeeded() next_row", next_row);
+ logDebug("generateSuffixIfNeeded filling_row", filling_row);
+ logDebug("generateSuffixIfNeeded next_row", next_row);
/// Determines if we should insert filling row before start generating next rows
- bool should_insert_first = (next_row < filling_row && !filling_row_inserted) || next_row.isNull();
+ bool should_insert_first = (next_row < filling_row && !filling_row_inserted) || (next_row.isNull() && !filling_row.isNull());
logDebug("should_insert_first", should_insert_first);
for (size_t i = 0, size = filling_row.size(); i < size; ++i)
- next_row[i] = filling_row.getFillDescription(i).fill_to;
+ next_row[i] = Field{};
- logDebug("generateSuffixIfNeeded() next_row updated", next_row);
+ logDebug("generateSuffixIfNeeded next_row updated", next_row);
- if (filling_row >= next_row)
+ if (!filling_row.hasSomeConstraints() || !filling_row.isConstraintsSatisfied())
{
- logDebug("generateSuffixIfNeeded()", "no need to generate suffix");
+ logDebug("generateSuffixIfNeeded", "will not generate suffix");
return false;
}
Block interpolate_block;
- if (should_insert_first && filling_row < next_row)
+ if (should_insert_first)
{
interpolate(result_columns, interpolate_block);
insertFromFillingRow(res_fill_columns, res_interpolate_columns, res_other_columns, interpolate_block);
@@ -516,9 +534,7 @@ bool FillingTransform::generateSuffixIfNeeded(
bool filling_row_changed = false;
while (true)
{
- const auto [apply, changed] = filling_row.next(next_row);
- filling_row_changed = changed;
- if (!apply)
+ if (!filling_row.next(next_row, filling_row_changed))
break;
interpolate(result_columns, interpolate_block);
@@ -595,7 +611,7 @@ void FillingTransform::transformRange(
if (!fill_from.isNull() && !equals(current_value, fill_from))
{
- filling_row.initFromDefaults(i);
+ filling_row.initUsingFrom(i);
filling_row_inserted = false;
if (less(fill_from, current_value, filling_row.getDirection(i)))
{
@@ -609,6 +625,9 @@ void FillingTransform::transformRange(
}
}
+ /// Init staleness first interval
+ filling_row.updateConstraintsWithStalenessRow(input_fill_columns, range_begin);
+
for (size_t row_ind = range_begin; row_ind < range_end; ++row_ind)
{
logDebug("row", row_ind);
@@ -619,21 +638,14 @@ void FillingTransform::transformRange(
logDebug("should_insert_first", should_insert_first);
for (size_t i = 0, size = filling_row.size(); i < size; ++i)
- {
- const auto current_value = (*input_fill_columns[i])[row_ind];
- const auto & fill_to = filling_row.getFillDescription(i).fill_to;
+ next_row[i] = (*input_fill_columns[i])[row_ind];
- if (fill_to.isNull() || less(current_value, fill_to, filling_row.getDirection(i)))
- next_row[i] = current_value;
- else
- next_row[i] = fill_to;
- }
logDebug("next_row updated", next_row);
/// The condition is true when filling row is initialized by value(s) in FILL FROM,
/// and there are row(s) in current range with value(s) < then in the filling row.
/// It can happen only once for a range.
- if (should_insert_first && filling_row < next_row)
+ if (should_insert_first && filling_row < next_row && filling_row.isConstraintsSatisfied())
{
interpolate(result_columns, interpolate_block);
insertFromFillingRow(res_fill_columns, res_interpolate_columns, res_other_columns, interpolate_block);
@@ -643,15 +655,37 @@ void FillingTransform::transformRange(
bool filling_row_changed = false;
while (true)
{
- const auto [apply, changed] = filling_row.next(next_row);
- filling_row_changed = changed;
- if (!apply)
+ if (!filling_row.next(next_row, filling_row_changed))
break;
interpolate(result_columns, interpolate_block);
insertFromFillingRow(res_fill_columns, res_interpolate_columns, res_other_columns, interpolate_block);
copyRowFromColumns(res_sort_prefix_columns, input_sort_prefix_columns, row_ind);
+ filling_row_changed = false;
}
+
+ if (running_with_staleness)
+ {
+ /// Initialize staleness border for current row to generate it's prefix
+ filling_row.updateConstraintsWithStalenessRow(input_fill_columns, row_ind);
+
+ while (filling_row.shift(next_row, filling_row_changed))
+ {
+ logDebug("filling_row after shift", filling_row);
+
+ do
+ {
+ logDebug("inserting prefix filling_row", filling_row);
+
+ interpolate(result_columns, interpolate_block);
+ insertFromFillingRow(res_fill_columns, res_interpolate_columns, res_other_columns, interpolate_block);
+ copyRowFromColumns(res_sort_prefix_columns, input_sort_prefix_columns, row_ind);
+ filling_row_changed = false;
+
+ } while (filling_row.next(next_row, filling_row_changed));
+ }
+ }
+
/// new valid filling row was generated but not inserted, will use it during suffix generation
if (filling_row_changed)
filling_row_inserted = false;
@@ -707,7 +741,7 @@ void FillingTransform::transform(Chunk & chunk)
/// if no data was processed, then need to initialize filling_row
if (last_row.empty())
{
- filling_row.initFromDefaults();
+ filling_row.initUsingFrom();
filling_row_inserted = false;
}
diff --git a/src/Processors/Transforms/FillingTransform.h b/src/Processors/Transforms/FillingTransform.h
index a8866a97103..92ca4fe6c9e 100644
--- a/src/Processors/Transforms/FillingTransform.h
+++ b/src/Processors/Transforms/FillingTransform.h
@@ -84,6 +84,7 @@ private:
SortDescription sort_prefix;
const InterpolateDescriptionPtr interpolate_description; /// Contains INTERPOLATE columns
+ bool running_with_staleness = false; /// True if STALENESS clause was used.
FillingRow filling_row; /// Current row, which is used to fill gaps.
FillingRow next_row; /// Row to which we need to generate filling rows.
bool filling_row_inserted = false;
diff --git a/src/Processors/Transforms/JoiningTransform.cpp b/src/Processors/Transforms/JoiningTransform.cpp
index 187f4bf6728..f2fb6327129 100644
--- a/src/Processors/Transforms/JoiningTransform.cpp
+++ b/src/Processors/Transforms/JoiningTransform.cpp
@@ -19,7 +19,6 @@ Block JoiningTransform::transformHeader(Block header, const JoinPtr & join)
join->initialize(header);
ExtraBlockPtr tmp;
join->joinBlock(header, tmp);
- materializeBlockInplace(header);
LOG_TEST(getLogger("JoiningTransform"), "After join block: '{}'", header.dumpStructure());
return header;
}
diff --git a/src/Processors/Transforms/MergeJoinTransform.cpp b/src/Processors/Transforms/MergeJoinTransform.cpp
index 1675e5d0386..77a437d4b97 100644
--- a/src/Processors/Transforms/MergeJoinTransform.cpp
+++ b/src/Processors/Transforms/MergeJoinTransform.cpp
@@ -394,7 +394,7 @@ void FullMergeJoinCursor::setChunk(Chunk && chunk)
convertToFullIfSparse(chunk);
current_chunk = std::move(chunk);
- cursor = SortCursorImpl(sample_block, current_chunk.getColumns(), desc);
+ cursor = SortCursorImpl(sample_block, current_chunk.getColumns(), current_chunk.getNumRows(), desc);
}
bool FullMergeJoinCursor::fullyCompleted() const
diff --git a/src/Processors/Transforms/SortingTransform.cpp b/src/Processors/Transforms/SortingTransform.cpp
index 6e65093e9e2..6a11354e2bf 100644
--- a/src/Processors/Transforms/SortingTransform.cpp
+++ b/src/Processors/Transforms/SortingTransform.cpp
@@ -42,7 +42,7 @@ MergeSorter::MergeSorter(const Block & header, Chunks chunks_, SortDescription &
/// Convert to full column, because some cursors expect non-contant columns
convertToFullIfConst(chunk);
- cursors.emplace_back(header, chunk.getColumns(), description, chunk_index);
+ cursors.emplace_back(header, chunk.getColumns(), chunk.getNumRows(), description, chunk_index);
has_collation |= cursors.back().has_collation;
nonempty_chunks.emplace_back(std::move(chunk));
diff --git a/src/Storages/MergeTree/MergeTreeIndexVectorSimilarity.cpp b/src/Storages/MergeTree/MergeTreeIndexVectorSimilarity.cpp
index 5a725922e14..f95b840e223 100644
--- a/src/Storages/MergeTree/MergeTreeIndexVectorSimilarity.cpp
+++ b/src/Storages/MergeTree/MergeTreeIndexVectorSimilarity.cpp
@@ -345,10 +345,11 @@ void MergeTreeIndexAggregatorVectorSimilarity::update(const Block & block, size_
throw Exception(ErrorCodes::INCORRECT_DATA, "Index granularity is too big: more than {} rows per index granule.", std::numeric_limits::max());
if (index_sample_block.columns() > 1)
- throw Exception(ErrorCodes::LOGICAL_ERROR, "Expected block with single column");
+ throw Exception(ErrorCodes::LOGICAL_ERROR, "Expected that index is build over a single column");
- const String & index_column_name = index_sample_block.getByPosition(0).name;
- const ColumnPtr & index_column = block.getByName(index_column_name).column;
+ const auto & index_column_name = index_sample_block.getByPosition(0).name;
+
+ const auto & index_column = block.getByName(index_column_name).column;
ColumnPtr column_cut = index_column->cut(*pos, rows_read);
const auto * column_array = typeid_cast(column_cut.get());
@@ -382,8 +383,7 @@ void MergeTreeIndexAggregatorVectorSimilarity::update(const Block & block, size_
if (index->size() + rows > std::numeric_limits::max())
throw Exception(ErrorCodes::INCORRECT_DATA, "Size of vector similarity index would exceed 4 billion entries");
- DataTypePtr data_type = block.getDataTypes()[0];
- const auto * data_type_array = typeid_cast(data_type.get());
+ const auto * data_type_array = typeid_cast(block.getByName(index_column_name).type.get());
if (!data_type_array)
throw Exception(ErrorCodes::LOGICAL_ERROR, "Expected data type Array(Float*)");
const TypeIndex nested_type_index = data_type_array->getNestedType()->getTypeId();
diff --git a/src/Storages/System/StorageSystemGrants.cpp b/src/Storages/System/StorageSystemGrants.cpp
index 5de1f8cef55..aa010e44388 100644
--- a/src/Storages/System/StorageSystemGrants.cpp
+++ b/src/Storages/System/StorageSystemGrants.cpp
@@ -30,8 +30,8 @@ ColumnsDescription StorageSystemGrants::getColumnsDescription()
{"column", std::make_shared(std::make_shared()), "Name of a column to which access is granted."},
{"is_partial_revoke", std::make_shared(),
"Logical value. It shows whether some privileges have been revoked. Possible values: "
- "0 — The row describes a partial revoke, "
- "1 — The row describes a grant."
+ "0 — The row describes a grant, "
+ "1 — The row describes a partial revoke."
},
{"grant_option", std::make_shared(), "Permission is granted WITH GRANT OPTION."},
};
diff --git a/tests/ci/ci_config.py b/tests/ci/ci_config.py
index 6d23b594b24..67cdbbdcf6d 100644
--- a/tests/ci/ci_config.py
+++ b/tests/ci/ci_config.py
@@ -51,11 +51,11 @@ class CI:
TAG_CONFIGS = {
Tags.DO_NOT_TEST_LABEL: LabelConfig(run_jobs=[JobNames.STYLE_CHECK]),
- Tags.CI_SET_ARM: LabelConfig(
+ Tags.CI_SET_AARCH64: LabelConfig(
run_jobs=[
JobNames.STYLE_CHECK,
BuildNames.PACKAGE_AARCH64,
- JobNames.INTEGRATION_TEST_ARM,
+ JobNames.INTEGRATION_TEST_AARCH64,
]
),
Tags.CI_SET_REQUIRED: LabelConfig(
@@ -95,16 +95,16 @@ class CI:
static_binary_name="aarch64",
additional_pkgs=True,
),
- runner_type=Runners.BUILDER_ARM,
+ runner_type=Runners.BUILDER_AARCH64,
),
- BuildNames.PACKAGE_ARM_ASAN: CommonJobConfigs.BUILD.with_properties(
+ BuildNames.PACKAGE_AARCH64_ASAN: CommonJobConfigs.BUILD.with_properties(
build_config=BuildConfig(
- name=BuildNames.PACKAGE_ARM_ASAN,
+ name=BuildNames.PACKAGE_AARCH64_ASAN,
compiler="clang-18-aarch64",
sanitizer="address",
package_type="deb",
),
- runner_type=Runners.BUILDER_ARM,
+ runner_type=Runners.BUILDER_AARCH64,
),
BuildNames.PACKAGE_ASAN: CommonJobConfigs.BUILD.with_properties(
build_config=BuildConfig(
@@ -276,16 +276,16 @@ class CI:
JobNames.INSTALL_TEST_AMD: CommonJobConfigs.INSTALL_TEST.with_properties(
required_builds=[BuildNames.PACKAGE_RELEASE]
),
- JobNames.INSTALL_TEST_ARM: CommonJobConfigs.INSTALL_TEST.with_properties(
+ JobNames.INSTALL_TEST_AARCH64: CommonJobConfigs.INSTALL_TEST.with_properties(
required_builds=[BuildNames.PACKAGE_AARCH64],
- runner_type=Runners.STYLE_CHECKER_ARM,
+ runner_type=Runners.STYLE_CHECKER_AARCH64,
),
JobNames.STATEFUL_TEST_ASAN: CommonJobConfigs.STATEFUL_TEST.with_properties(
required_builds=[BuildNames.PACKAGE_ASAN]
),
- JobNames.STATEFUL_TEST_ARM_ASAN: CommonJobConfigs.STATEFUL_TEST.with_properties(
- required_builds=[BuildNames.PACKAGE_ARM_ASAN],
- runner_type=Runners.FUNC_TESTER_ARM,
+ JobNames.STATEFUL_TEST_AARCH64_ASAN: CommonJobConfigs.STATEFUL_TEST.with_properties(
+ required_builds=[BuildNames.PACKAGE_AARCH64_ASAN],
+ runner_type=Runners.FUNC_TESTER_AARCH64,
),
JobNames.STATEFUL_TEST_TSAN: CommonJobConfigs.STATEFUL_TEST.with_properties(
required_builds=[BuildNames.PACKAGE_TSAN]
@@ -307,7 +307,7 @@ class CI:
),
JobNames.STATEFUL_TEST_AARCH64: CommonJobConfigs.STATEFUL_TEST.with_properties(
required_builds=[BuildNames.PACKAGE_AARCH64],
- runner_type=Runners.FUNC_TESTER_ARM,
+ runner_type=Runners.FUNC_TESTER_AARCH64,
),
JobNames.STATEFUL_TEST_PARALLEL_REPL_RELEASE: CommonJobConfigs.STATEFUL_TEST.with_properties(
required_builds=[BuildNames.PACKAGE_RELEASE]
@@ -335,10 +335,10 @@ class CI:
JobNames.STATELESS_TEST_ASAN: CommonJobConfigs.STATELESS_TEST.with_properties(
required_builds=[BuildNames.PACKAGE_ASAN], num_batches=2
),
- JobNames.STATELESS_TEST_ARM_ASAN: CommonJobConfigs.STATELESS_TEST.with_properties(
- required_builds=[BuildNames.PACKAGE_ARM_ASAN],
+ JobNames.STATELESS_TEST_AARCH64_ASAN: CommonJobConfigs.STATELESS_TEST.with_properties(
+ required_builds=[BuildNames.PACKAGE_AARCH64_ASAN],
num_batches=2,
- runner_type=Runners.FUNC_TESTER_ARM,
+ runner_type=Runners.FUNC_TESTER_AARCH64,
),
JobNames.STATELESS_TEST_TSAN: CommonJobConfigs.STATELESS_TEST.with_properties(
required_builds=[BuildNames.PACKAGE_TSAN], num_batches=4
@@ -360,7 +360,7 @@ class CI:
),
JobNames.STATELESS_TEST_AARCH64: CommonJobConfigs.STATELESS_TEST.with_properties(
required_builds=[BuildNames.PACKAGE_AARCH64],
- runner_type=Runners.FUNC_TESTER_ARM,
+ runner_type=Runners.FUNC_TESTER_AARCH64,
),
JobNames.STATELESS_TEST_OLD_ANALYZER_S3_REPLICATED_RELEASE: CommonJobConfigs.STATELESS_TEST.with_properties(
required_builds=[BuildNames.PACKAGE_RELEASE], num_batches=2
@@ -432,10 +432,10 @@ class CI:
num_batches=6,
timeout=9000, # the job timed out with default value (7200)
),
- JobNames.INTEGRATION_TEST_ARM: CommonJobConfigs.INTEGRATION_TEST.with_properties(
+ JobNames.INTEGRATION_TEST_AARCH64: CommonJobConfigs.INTEGRATION_TEST.with_properties(
required_builds=[BuildNames.PACKAGE_AARCH64],
num_batches=6,
- runner_type=Runners.FUNC_TESTER_ARM,
+ runner_type=Runners.FUNC_TESTER_AARCH64,
),
JobNames.INTEGRATION_TEST: CommonJobConfigs.INTEGRATION_TEST.with_properties(
required_builds=[BuildNames.PACKAGE_RELEASE],
@@ -453,10 +453,10 @@ class CI:
required_builds=[BuildNames.PACKAGE_RELEASE],
required_on_release_branch=True,
),
- JobNames.COMPATIBILITY_TEST_ARM: CommonJobConfigs.COMPATIBILITY_TEST.with_properties(
+ JobNames.COMPATIBILITY_TEST_AARCH64: CommonJobConfigs.COMPATIBILITY_TEST.with_properties(
required_builds=[BuildNames.PACKAGE_AARCH64],
required_on_release_branch=True,
- runner_type=Runners.STYLE_CHECKER_ARM,
+ runner_type=Runners.STYLE_CHECKER_AARCH64,
),
JobNames.UNIT_TEST: CommonJobConfigs.UNIT_TEST.with_properties(
required_builds=[BuildNames.BINARY_RELEASE],
@@ -499,22 +499,22 @@ class CI:
required_builds=[BuildNames.BINARY_RELEASE],
run_by_labels=[Labels.JEPSEN_TEST],
run_command="jepsen_check.py keeper",
- runner_type=Runners.STYLE_CHECKER_ARM,
+ runner_type=Runners.STYLE_CHECKER_AARCH64,
),
JobNames.JEPSEN_SERVER: JobConfig(
required_builds=[BuildNames.BINARY_RELEASE],
run_by_labels=[Labels.JEPSEN_TEST],
run_command="jepsen_check.py server",
- runner_type=Runners.STYLE_CHECKER_ARM,
+ runner_type=Runners.STYLE_CHECKER_AARCH64,
),
JobNames.PERFORMANCE_TEST_AMD64: CommonJobConfigs.PERF_TESTS.with_properties(
required_builds=[BuildNames.PACKAGE_RELEASE], num_batches=4
),
- JobNames.PERFORMANCE_TEST_ARM64: CommonJobConfigs.PERF_TESTS.with_properties(
+ JobNames.PERFORMANCE_TEST_AARCH64: CommonJobConfigs.PERF_TESTS.with_properties(
required_builds=[BuildNames.PACKAGE_AARCH64],
num_batches=4,
run_by_labels=[Labels.PR_PERFORMANCE],
- runner_type=Runners.FUNC_TESTER_ARM,
+ runner_type=Runners.FUNC_TESTER_AARCH64,
),
JobNames.SQLANCER: CommonJobConfigs.SQLLANCER_TEST.with_properties(
required_builds=[BuildNames.PACKAGE_RELEASE],
@@ -532,9 +532,9 @@ class CI:
JobNames.CLICKBENCH_TEST: CommonJobConfigs.CLICKBENCH_TEST.with_properties(
required_builds=[BuildNames.PACKAGE_RELEASE],
),
- JobNames.CLICKBENCH_TEST_ARM: CommonJobConfigs.CLICKBENCH_TEST.with_properties(
+ JobNames.CLICKBENCH_TEST_AARCH64: CommonJobConfigs.CLICKBENCH_TEST.with_properties(
required_builds=[BuildNames.PACKAGE_AARCH64],
- runner_type=Runners.FUNC_TESTER_ARM,
+ runner_type=Runners.FUNC_TESTER_AARCH64,
),
JobNames.LIBFUZZER_TEST: JobConfig(
required_builds=[BuildNames.FUZZERS],
@@ -572,7 +572,7 @@ class CI:
),
JobNames.STYLE_CHECK: JobConfig(
run_always=True,
- runner_type=Runners.STYLE_CHECKER_ARM,
+ runner_type=Runners.STYLE_CHECKER_AARCH64,
),
JobNames.BUGFIX_VALIDATE: JobConfig(
run_by_labels=[Labels.PR_BUGFIX, Labels.PR_CRITICAL_BUGFIX],
diff --git a/tests/ci/ci_definitions.py b/tests/ci/ci_definitions.py
index dd86dc320c2..fb3e55fdbe3 100644
--- a/tests/ci/ci_definitions.py
+++ b/tests/ci/ci_definitions.py
@@ -58,11 +58,11 @@ class Runners(metaclass=WithIter):
"""
BUILDER = "builder"
- BUILDER_ARM = "builder-aarch64"
+ BUILDER_AARCH64 = "builder-aarch64"
STYLE_CHECKER = "style-checker"
- STYLE_CHECKER_ARM = "style-checker-aarch64"
+ STYLE_CHECKER_AARCH64 = "style-checker-aarch64"
FUNC_TESTER = "func-tester"
- FUNC_TESTER_ARM = "func-tester-aarch64"
+ FUNC_TESTER_AARCH64 = "func-tester-aarch64"
FUZZER_UNIT_TESTER = "fuzzer-unit-tester"
@@ -78,7 +78,7 @@ class Tags(metaclass=WithIter):
# to upload all binaries from build jobs
UPLOAD_ALL_ARTIFACTS = "upload_all"
CI_SET_SYNC = "ci_set_sync"
- CI_SET_ARM = "ci_set_arm"
+ CI_SET_AARCH64 = "ci_set_aarch64"
CI_SET_REQUIRED = "ci_set_required"
CI_SET_BUILDS = "ci_set_builds"
@@ -106,7 +106,7 @@ class BuildNames(metaclass=WithIter):
PACKAGE_MSAN = "package_msan"
PACKAGE_DEBUG = "package_debug"
PACKAGE_AARCH64 = "package_aarch64"
- PACKAGE_ARM_ASAN = "package_aarch64_asan"
+ PACKAGE_AARCH64_ASAN = "package_aarch64_asan"
PACKAGE_RELEASE_COVERAGE = "package_release_coverage"
BINARY_RELEASE = "binary_release"
BINARY_TIDY = "binary_tidy"
@@ -134,14 +134,14 @@ class JobNames(metaclass=WithIter):
DOCKER_SERVER = "Docker server image"
DOCKER_KEEPER = "Docker keeper image"
INSTALL_TEST_AMD = "Install packages (release)"
- INSTALL_TEST_ARM = "Install packages (aarch64)"
+ INSTALL_TEST_AARCH64 = "Install packages (aarch64)"
STATELESS_TEST_DEBUG = "Stateless tests (debug)"
STATELESS_TEST_RELEASE = "Stateless tests (release)"
STATELESS_TEST_RELEASE_COVERAGE = "Stateless tests (coverage)"
STATELESS_TEST_AARCH64 = "Stateless tests (aarch64)"
STATELESS_TEST_ASAN = "Stateless tests (asan)"
- STATELESS_TEST_ARM_ASAN = "Stateless tests (aarch64, asan)"
+ STATELESS_TEST_AARCH64_ASAN = "Stateless tests (aarch64, asan)"
STATELESS_TEST_TSAN = "Stateless tests (tsan)"
STATELESS_TEST_MSAN = "Stateless tests (msan)"
STATELESS_TEST_UBSAN = "Stateless tests (ubsan)"
@@ -158,7 +158,7 @@ class JobNames(metaclass=WithIter):
STATEFUL_TEST_RELEASE_COVERAGE = "Stateful tests (coverage)"
STATEFUL_TEST_AARCH64 = "Stateful tests (aarch64)"
STATEFUL_TEST_ASAN = "Stateful tests (asan)"
- STATEFUL_TEST_ARM_ASAN = "Stateful tests (aarch64, asan)"
+ STATEFUL_TEST_AARCH64_ASAN = "Stateful tests (aarch64, asan)"
STATEFUL_TEST_TSAN = "Stateful tests (tsan)"
STATEFUL_TEST_MSAN = "Stateful tests (msan)"
STATEFUL_TEST_UBSAN = "Stateful tests (ubsan)"
@@ -181,7 +181,7 @@ class JobNames(metaclass=WithIter):
INTEGRATION_TEST_ASAN = "Integration tests (asan)"
INTEGRATION_TEST_ASAN_OLD_ANALYZER = "Integration tests (asan, old analyzer)"
INTEGRATION_TEST_TSAN = "Integration tests (tsan)"
- INTEGRATION_TEST_ARM = "Integration tests (aarch64)"
+ INTEGRATION_TEST_AARCH64 = "Integration tests (aarch64)"
INTEGRATION_TEST_FLAKY = "Integration tests flaky check (asan)"
UPGRADE_TEST_DEBUG = "Upgrade check (debug)"
@@ -205,7 +205,7 @@ class JobNames(metaclass=WithIter):
JEPSEN_SERVER = "ClickHouse Server Jepsen"
PERFORMANCE_TEST_AMD64 = "Performance Comparison (release)"
- PERFORMANCE_TEST_ARM64 = "Performance Comparison (aarch64)"
+ PERFORMANCE_TEST_AARCH64 = "Performance Comparison (aarch64)"
# SQL_LOGIC_TEST = "Sqllogic test (release)"
@@ -214,10 +214,10 @@ class JobNames(metaclass=WithIter):
SQLTEST = "SQLTest"
COMPATIBILITY_TEST = "Compatibility check (release)"
- COMPATIBILITY_TEST_ARM = "Compatibility check (aarch64)"
+ COMPATIBILITY_TEST_AARCH64 = "Compatibility check (aarch64)"
CLICKBENCH_TEST = "ClickBench (release)"
- CLICKBENCH_TEST_ARM = "ClickBench (aarch64)"
+ CLICKBENCH_TEST_AARCH64 = "ClickBench (aarch64)"
LIBFUZZER_TEST = "libFuzzer tests"
@@ -387,7 +387,7 @@ class CommonJobConfigs:
"./tests/ci/upload_result_helper.py",
],
),
- runner_type=Runners.STYLE_CHECKER_ARM,
+ runner_type=Runners.STYLE_CHECKER_AARCH64,
disable_await=True,
)
COMPATIBILITY_TEST = JobConfig(
@@ -634,8 +634,8 @@ REQUIRED_CHECKS = [
JobNames.STATEFUL_TEST_RELEASE,
JobNames.STATELESS_TEST_RELEASE,
JobNames.STATELESS_TEST_ASAN,
- JobNames.STATELESS_TEST_ARM_ASAN,
- JobNames.STATEFUL_TEST_ARM_ASAN,
+ JobNames.STATELESS_TEST_AARCH64_ASAN,
+ JobNames.STATEFUL_TEST_AARCH64_ASAN,
JobNames.STATELESS_TEST_FLAKY_ASAN,
JobNames.STATEFUL_TEST_ASAN,
JobNames.STYLE_CHECK,
diff --git a/tests/ci/compatibility_check.py b/tests/ci/compatibility_check.py
index bb0c717160e..38fb2eceb28 100644
--- a/tests/ci/compatibility_check.py
+++ b/tests/ci/compatibility_check.py
@@ -131,7 +131,7 @@ def main():
check_name = args.check_name or os.getenv("CHECK_NAME")
assert check_name
check_glibc = True
- # currently hardcoded to x86, don't enable for ARM
+ # currently hardcoded to x86, don't enable for AARCH64
check_distributions = (
"aarch64" not in check_name.lower() and "arm64" not in check_name.lower()
)
diff --git a/tests/ci/test_ci_config.py b/tests/ci/test_ci_config.py
index 0e396b827ea..65418310c31 100644
--- a/tests/ci/test_ci_config.py
+++ b/tests/ci/test_ci_config.py
@@ -36,11 +36,12 @@ class TestCIConfig(unittest.TestCase):
elif "binary_" in job.lower() or "package_" in job.lower():
if job.lower() in (
CI.BuildNames.PACKAGE_AARCH64,
- CI.BuildNames.PACKAGE_ARM_ASAN,
+ CI.BuildNames.PACKAGE_AARCH64_ASAN,
):
self.assertTrue(
- CI.JOB_CONFIGS[job].runner_type in (CI.Runners.BUILDER_ARM,),
- f"Job [{job}] must have [{CI.Runners.BUILDER_ARM}] runner",
+ CI.JOB_CONFIGS[job].runner_type
+ in (CI.Runners.BUILDER_AARCH64,),
+ f"Job [{job}] must have [{CI.Runners.BUILDER_AARCH64}] runner",
)
else:
self.assertTrue(
@@ -96,7 +97,7 @@ class TestCIConfig(unittest.TestCase):
else:
self.assertTrue(CI.JOB_CONFIGS[job].build_config is None)
if "asan" in job and "aarch" in job:
- expected_builds = [CI.BuildNames.PACKAGE_ARM_ASAN]
+ expected_builds = [CI.BuildNames.PACKAGE_AARCH64_ASAN]
elif "asan" in job:
expected_builds = [CI.BuildNames.PACKAGE_ASAN]
elif "msan" in job:
diff --git a/tests/ci/test_ci_options.py b/tests/ci/test_ci_options.py
index 536e18758f8..e1b780387e7 100644
--- a/tests/ci/test_ci_options.py
+++ b/tests/ci/test_ci_options.py
@@ -10,7 +10,7 @@ from ci_settings import CiSettings
_TEST_BODY_1 = """
#### Run only:
- [ ] Some Set
-- [x] Integration tests (arm64)
+- [x] Integration tests (aarch64)
- [x] Integration tests
- [x] Integration tests
- [ ] Integration tests
@@ -150,7 +150,7 @@ class TestCIOptions(unittest.TestCase):
self.assertFalse(ci_options.no_ci_cache)
self.assertTrue(ci_options.no_merge_commit)
self.assertTrue(ci_options.woolen_wolfdog)
- self.assertEqual(ci_options.ci_sets, ["ci_set_arm"])
+ self.assertEqual(ci_options.ci_sets, ["ci_set_aarch64"])
self.assertCountEqual(ci_options.include_keywords, ["foo", "foo_bar"])
self.assertCountEqual(ci_options.exclude_keywords, ["foo", "foo_bar"])
diff --git a/tests/clickhouse-test b/tests/clickhouse-test
index f4c3b368632..9c035b7cc35 100755
--- a/tests/clickhouse-test
+++ b/tests/clickhouse-test
@@ -789,7 +789,6 @@ def get_localzone():
return os.getenv("TZ", "/".join(os.readlink("/etc/localtime").split("/")[-2:]))
-# Refer to `tests/integration/helpers/random_settings.py` for integration test random settings
class SettingsRandomizer:
settings = {
"max_insert_threads": lambda: (
@@ -920,9 +919,6 @@ class SettingsRandomizer:
"max_parsing_threads": lambda: random.choice([0, 1, 10]),
"optimize_functions_to_subcolumns": lambda: random.randint(0, 1),
"parallel_replicas_local_plan": lambda: random.randint(0, 1),
- "query_plan_join_inner_table_selection": lambda: random.choice(
- ["left", "auto", "right"]
- ),
"output_format_native_write_json_as_string": lambda: random.randint(0, 1),
"enable_vertical_final": lambda: random.randint(0, 1),
}
diff --git a/tests/fuzz/dictionaries/keywords.dict b/tests/fuzz/dictionaries/keywords.dict
index abaaf9e53b5..a37675ebcad 100644
--- a/tests/fuzz/dictionaries/keywords.dict
+++ b/tests/fuzz/dictionaries/keywords.dict
@@ -538,6 +538,7 @@
"WITH ADMIN OPTION"
"WITH CHECK"
"WITH FILL"
+"STALENESS"
"WITH GRANT OPTION"
"WITH NAME"
"WITH REPLACE OPTION"
diff --git a/tests/integration/helpers/cluster.py b/tests/integration/helpers/cluster.py
index 6751f205fb8..b24593602ec 100644
--- a/tests/integration/helpers/cluster.py
+++ b/tests/integration/helpers/cluster.py
@@ -67,7 +67,6 @@ DEFAULT_ENV_NAME = ".env"
DEFAULT_BASE_CONFIG_DIR = os.environ.get(
"CLICKHOUSE_TESTS_BASE_CONFIG_DIR", "/etc/clickhouse-server/"
)
-DOCKER_BASE_TAG = os.environ.get("DOCKER_BASE_TAG", "latest")
SANITIZER_SIGN = "=================="
@@ -504,6 +503,7 @@ class ClickHouseCluster:
"CLICKHOUSE_TESTS_DOCKERD_HOST"
)
self.docker_api_version = os.environ.get("DOCKER_API_VERSION")
+ self.docker_base_tag = os.environ.get("DOCKER_BASE_TAG", "latest")
self.base_cmd = ["docker", "compose"]
if custom_dockerd_host:
@@ -1079,7 +1079,7 @@ class ClickHouseCluster:
env_variables["keeper_binary"] = binary_path
env_variables["keeper_cmd_prefix"] = keeper_cmd_prefix
- env_variables["image"] = "clickhouse/integration-test:" + DOCKER_BASE_TAG
+ env_variables["image"] = "clickhouse/integration-test:" + self.docker_base_tag
env_variables["user"] = str(os.getuid())
env_variables["keeper_fs"] = "bind"
for i in range(1, 4):
@@ -1653,6 +1653,7 @@ class ClickHouseCluster:
copy_common_configs=True,
config_root_name="clickhouse",
extra_configs=[],
+ extra_args="",
randomize_settings=True,
) -> "ClickHouseInstance":
"""Add an instance to the cluster.
@@ -1675,7 +1676,7 @@ class ClickHouseCluster:
)
if tag is None:
- tag = DOCKER_BASE_TAG
+ tag = self.docker_base_tag
if not env_variables:
env_variables = {}
self.use_keeper = use_keeper
@@ -1740,6 +1741,7 @@ class ClickHouseCluster:
with_postgres_cluster=with_postgres_cluster,
with_postgresql_java_client=with_postgresql_java_client,
clickhouse_start_command=clickhouse_start_command,
+ clickhouse_start_extra_args=extra_args,
main_config_name=main_config_name,
users_config_name=users_config_name,
copy_common_configs=copy_common_configs,
@@ -3368,6 +3370,7 @@ class ClickHouseInstance:
with_postgres_cluster,
with_postgresql_java_client,
clickhouse_start_command=CLICKHOUSE_START_COMMAND,
+ clickhouse_start_extra_args="",
main_config_name="config.xml",
users_config_name="users.xml",
copy_common_configs=True,
@@ -3463,11 +3466,18 @@ class ClickHouseInstance:
self.users_config_name = users_config_name
self.copy_common_configs = copy_common_configs
- self.clickhouse_start_command = clickhouse_start_command.replace(
+ clickhouse_start_command_with_conf = clickhouse_start_command.replace(
"{main_config_file}", self.main_config_name
)
- self.clickhouse_stay_alive_command = "bash -c \"trap 'pkill tail' INT TERM; {} --daemon; coproc tail -f /dev/null; wait $$!\"".format(
- clickhouse_start_command
+
+ self.clickhouse_start_command = "{} -- {}".format(
+ clickhouse_start_command_with_conf, clickhouse_start_extra_args
+ )
+ self.clickhouse_start_command_in_daemon = "{} --daemon -- {}".format(
+ clickhouse_start_command_with_conf, clickhouse_start_extra_args
+ )
+ self.clickhouse_stay_alive_command = "bash -c \"trap 'pkill tail' INT TERM; {}; coproc tail -f /dev/null; wait $$!\"".format(
+ self.clickhouse_start_command_in_daemon
)
self.path = p.join(self.cluster.instances_dir, name)
@@ -3910,7 +3920,7 @@ class ClickHouseInstance:
if pid is None:
logging.debug("No clickhouse process running. Start new one.")
self.exec_in_container(
- ["bash", "-c", "{} --daemon".format(self.clickhouse_start_command)],
+ ["bash", "-c", self.clickhouse_start_command_in_daemon],
user=str(os.getuid()),
)
if expected_to_fail:
@@ -4230,7 +4240,7 @@ class ClickHouseInstance:
user="root",
)
self.exec_in_container(
- ["bash", "-c", "{} --daemon".format(self.clickhouse_start_command)],
+ ["bash", "-c", self.clickhouse_start_command_in_daemon],
user=str(os.getuid()),
)
@@ -4311,7 +4321,7 @@ class ClickHouseInstance:
]
)
self.exec_in_container(
- ["bash", "-c", "{} --daemon".format(self.clickhouse_start_command)],
+ ["bash", "-c", self.clickhouse_start_command_in_daemon],
user=str(os.getuid()),
)
@@ -4538,12 +4548,7 @@ class ClickHouseInstance:
if len(self.custom_dictionaries_paths):
write_embedded_config("0_common_enable_dictionaries.xml", self.config_d_dir)
- if (
- self.randomize_settings
- and self.image == "clickhouse/integration-test"
- and self.tag == DOCKER_BASE_TAG
- and self.base_config_dir == DEFAULT_BASE_CONFIG_DIR
- ):
+ if self.randomize_settings and self.base_config_dir == DEFAULT_BASE_CONFIG_DIR:
# If custom main config is used, do not apply random settings to it
write_random_settings_config(Path(users_d_dir) / "0_random_settings.xml")
@@ -4704,9 +4709,7 @@ class ClickHouseInstance:
entrypoint_cmd = self.clickhouse_start_command
if self.stay_alive:
- entrypoint_cmd = self.clickhouse_stay_alive_command.replace(
- "{main_config_file}", self.main_config_name
- )
+ entrypoint_cmd = self.clickhouse_stay_alive_command
else:
entrypoint_cmd = (
"["
diff --git a/tests/integration/helpers/random_settings.py b/tests/integration/helpers/random_settings.py
index 32cde54d0e7..b2319561fd7 100644
--- a/tests/integration/helpers/random_settings.py
+++ b/tests/integration/helpers/random_settings.py
@@ -5,8 +5,6 @@ def randomize_settings():
yield "max_joined_block_size_rows", random.randint(8000, 100000)
if random.random() < 0.5:
yield "max_block_size", random.randint(8000, 100000)
- if random.random() < 0.5:
- yield "query_plan_join_inner_table_selection", random.choice(["auto", "left"])
def write_random_settings_config(destination):
diff --git a/tests/integration/test_peak_memory_usage/test.py b/tests/integration/test_peak_memory_usage/test.py
index 69057573173..51268dcf386 100644
--- a/tests/integration/test_peak_memory_usage/test.py
+++ b/tests/integration/test_peak_memory_usage/test.py
@@ -91,7 +91,7 @@ def test_clickhouse_client_max_peak_memory_usage_distributed(started_cluster):
with client(name="client1>", log=client_output, command=command_text) as client1:
client1.expect(prompt)
client1.send(
- "SELECT COUNT(*) FROM distributed_fixed_numbers JOIN fixed_numbers_2 ON distributed_fixed_numbers.number=fixed_numbers_2.number SETTINGS query_plan_join_inner_table_selection = 'right'",
+ "SELECT COUNT(*) FROM distributed_fixed_numbers JOIN fixed_numbers_2 ON distributed_fixed_numbers.number=fixed_numbers_2.number",
)
client1.expect("Peak memory usage", timeout=60)
client1.expect(prompt)
diff --git a/tests/integration/test_replicated_s3_zero_copy_drop_partition/test.py b/tests/integration/test_replicated_s3_zero_copy_drop_partition/test.py
index 6d2bb0a3b70..7623a24c0ef 100644
--- a/tests/integration/test_replicated_s3_zero_copy_drop_partition/test.py
+++ b/tests/integration/test_replicated_s3_zero_copy_drop_partition/test.py
@@ -65,12 +65,24 @@ CREATE TABLE test_s3(c1 Int8, c2 Date) ENGINE = ReplicatedMergeTree('/test/table
objects_after = get_objects_in_data_path()
assert objects_before == objects_after
+ node1.query("DROP TABLE test_local SYNC")
+ node1.query("DROP TABLE test_s3 SYNC")
def test_drop_complex_columns(started_cluster):
+ node1 = cluster.instances["node1"]
+ node1.query(
+ """
+CREATE TABLE warming_up(
+id Int8
+) ENGINE = MergeTree
+order by (id) SETTINGS storage_policy = 's3';"""
+ )
+
+ # Now we are sure that s3 storage is up and running
start_objects = get_objects_in_data_path()
print("Objects before", start_objects)
- node1 = cluster.instances["node1"]
+
node1.query(
"""
CREATE TABLE test_s3_complex_types(
@@ -104,3 +116,4 @@ vertical_merge_algorithm_min_columns_to_activate=1;"""
end_objects = get_objects_in_data_path()
print("Objects after drop", end_objects)
assert start_objects == end_objects
+ node1.query("DROP TABLE warming_up SYNC")
diff --git a/tests/queries/0_stateless/00826_cross_to_inner_join.sql b/tests/queries/0_stateless/00826_cross_to_inner_join.sql
index 5ab7a2d0626..e9f9e13e2d3 100644
--- a/tests/queries/0_stateless/00826_cross_to_inner_join.sql
+++ b/tests/queries/0_stateless/00826_cross_to_inner_join.sql
@@ -15,9 +15,9 @@ INSERT INTO t2_00826 values (1,1), (1,2);
INSERT INTO t2_00826 (a) values (2), (3);
SELECT '--- cross ---';
-SELECT * FROM t1_00826 cross join t2_00826 where t1_00826.a = t2_00826.a ORDER BY ALL;
+SELECT * FROM t1_00826 cross join t2_00826 where t1_00826.a = t2_00826.a;
SELECT '--- cross nullable ---';
-SELECT * FROM t1_00826 cross join t2_00826 where t1_00826.b = t2_00826.b ORDER BY ALL;
+SELECT * FROM t1_00826 cross join t2_00826 where t1_00826.b = t2_00826.b;
SELECT '--- cross nullable vs not nullable ---';
SELECT * FROM t1_00826 cross join t2_00826 where t1_00826.a = t2_00826.b ORDER BY t1_00826.a;
SELECT '--- cross self ---';
@@ -41,15 +41,14 @@ SELECT '--- is null or ---';
SELECT * FROM t1_00826 cross join t2_00826 where t1_00826.b = t2_00826.a AND (t2_00826.b IS NULL OR t2_00826.b > t2_00826.a) ORDER BY t1_00826.a;
SELECT '--- do not rewrite alias ---';
-SELECT a as b FROM t1_00826 cross join t2_00826 where t1_00826.b = t2_00826.a AND b > 0 ORDER BY ALL;
+SELECT a as b FROM t1_00826 cross join t2_00826 where t1_00826.b = t2_00826.a AND b > 0;
SELECT '--- comma ---';
-SELECT * FROM t1_00826, t2_00826 where t1_00826.a = t2_00826.a ORDER BY ALL;
+SELECT * FROM t1_00826, t2_00826 where t1_00826.a = t2_00826.a;
SELECT '--- comma nullable ---';
-SELECT * FROM t1_00826, t2_00826 where t1_00826.b = t2_00826.b ORDER BY ALL;
+SELECT * FROM t1_00826, t2_00826 where t1_00826.b = t2_00826.b;
SELECT '--- comma and or ---';
-SELECT * FROM t1_00826, t2_00826 where t1_00826.a = t2_00826.a AND (t2_00826.b IS NULL OR t2_00826.b < 2)
-ORDER BY ALL;
+SELECT * FROM t1_00826, t2_00826 where t1_00826.a = t2_00826.a AND (t2_00826.b IS NULL OR t2_00826.b < 2);
SELECT '--- cross ---';
diff --git a/tests/queries/0_stateless/00847_multiple_join_same_column.sql b/tests/queries/0_stateless/00847_multiple_join_same_column.sql
index bbb4eb12466..c7f0c6383c2 100644
--- a/tests/queries/0_stateless/00847_multiple_join_same_column.sql
+++ b/tests/queries/0_stateless/00847_multiple_join_same_column.sql
@@ -20,42 +20,42 @@ select t.a, s.b, s.a, s.b, y.a, y.b from t
left join s on (t.a = s.a and s.b = t.b)
left join y on (y.a = s.a and y.b = s.b)
order by t.a
-format PrettyCompactMonoBlock;
+format PrettyCompactNoEscapes;
select t.a as t_a from t
left join s on s.a = t_a
order by t.a
-format PrettyCompactMonoBlock;
+format PrettyCompactNoEscapes;
select t.a, s.a as s_a from t
left join s on s.a = t.a
left join y on y.b = s.b
order by t.a
-format PrettyCompactMonoBlock;
+format PrettyCompactNoEscapes;
select t.a, t.a, t.b as t_b from t
left join s on t.a = s.a
left join y on y.b = s.b
order by t.a
-format PrettyCompactMonoBlock;
+format PrettyCompactNoEscapes;
select s.a, s.a, s.b as s_b, s.b from t
left join s on s.a = t.a
left join y on s.b = y.b
order by t.a
-format PrettyCompactMonoBlock;
+format PrettyCompactNoEscapes;
select y.a, y.a, y.b as y_b, y.b from t
left join s on s.a = t.a
left join y on y.b = s.b
order by t.a
-format PrettyCompactMonoBlock;
+format PrettyCompactNoEscapes;
select t.a, t.a as t_a, s.a, s.a as s_a, y.a, y.a as y_a from t
left join s on t.a = s.a
left join y on y.b = s.b
order by t.a
-format PrettyCompactMonoBlock;
+format PrettyCompactNoEscapes;
drop table t;
drop table s;
diff --git a/tests/queries/0_stateless/01015_empty_in_inner_right_join.sql.j2 b/tests/queries/0_stateless/01015_empty_in_inner_right_join.sql.j2
index cdbb0542ffb..cdb9d253b9b 100644
--- a/tests/queries/0_stateless/01015_empty_in_inner_right_join.sql.j2
+++ b/tests/queries/0_stateless/01015_empty_in_inner_right_join.sql.j2
@@ -1,7 +1,5 @@
SET joined_subquery_requires_alias = 0;
-SET query_plan_join_inner_table_selection = 'auto';
-
{% for join_algorithm in ['partial_merge', 'hash'] -%}
SET join_algorithm = '{{ join_algorithm }}';
diff --git a/tests/queries/0_stateless/01107_join_right_table_totals.reference b/tests/queries/0_stateless/01107_join_right_table_totals.reference
index aa569ff9331..daf503b776d 100644
--- a/tests/queries/0_stateless/01107_join_right_table_totals.reference
+++ b/tests/queries/0_stateless/01107_join_right_table_totals.reference
@@ -18,35 +18,28 @@
0 0
0 0
--
1 1
1 1
0 0
--
1 1
1 1
0 0
--
1 1
1 1
0 0
--
1 1
1 1
0 0
--
1 1
0 0
--
1 foo 1 1 300
0 foo 1 0 300
--
1 100 1970-01-01 1 100 1970-01-01
1 100 1970-01-01 1 200 1970-01-02
1 200 1970-01-02 1 100 1970-01-01
diff --git a/tests/queries/0_stateless/01107_join_right_table_totals.sql b/tests/queries/0_stateless/01107_join_right_table_totals.sql
index 7e549282489..ad8954d5d70 100644
--- a/tests/queries/0_stateless/01107_join_right_table_totals.sql
+++ b/tests/queries/0_stateless/01107_join_right_table_totals.sql
@@ -64,47 +64,39 @@ USING (id);
INSERT INTO t VALUES (1, 100, '1970-01-01'), (1, 200, '1970-01-02');
-SELECT '-';
SELECT *
FROM (SELECT item_id FROM t GROUP BY item_id WITH TOTALS ORDER BY item_id) l
LEFT JOIN (SELECT item_id FROM t ) r
ON l.item_id = r.item_id;
-SELECT '-';
SELECT *
FROM (SELECT item_id FROM t GROUP BY item_id WITH TOTALS ORDER BY item_id) l
RIGHT JOIN (SELECT item_id FROM t ) r
ON l.item_id = r.item_id;
-SELECT '-';
SELECT *
FROM (SELECT item_id FROM t) l
LEFT JOIN (SELECT item_id FROM t GROUP BY item_id WITH TOTALS ORDER BY item_id ) r
ON l.item_id = r.item_id;
-SELECT '-';
SELECT *
FROM (SELECT item_id FROM t) l
RIGHT JOIN (SELECT item_id FROM t GROUP BY item_id WITH TOTALS ORDER BY item_id ) r
ON l.item_id = r.item_id;
-SELECT '-';
SELECT *
FROM (SELECT item_id FROM t GROUP BY item_id WITH TOTALS ORDER BY item_id) l
LEFT JOIN (SELECT item_id FROM t GROUP BY item_id WITH TOTALS ORDER BY item_id ) r
ON l.item_id = r.item_id;
-SELECT '-';
SELECT *
FROM (SELECT item_id, 'foo' AS key, 1 AS val FROM t GROUP BY item_id WITH TOTALS ORDER BY item_id) l
LEFT JOIN (SELECT item_id, sum(price_sold) AS val FROM t GROUP BY item_id WITH TOTALS ORDER BY item_id ) r
ON l.item_id = r.item_id;
-SELECT '-';
SELECT *
FROM (SELECT * FROM t GROUP BY item_id, price_sold, date WITH TOTALS ORDER BY item_id, price_sold, date) l
LEFT JOIN (SELECT * FROM t GROUP BY item_id, price_sold, date WITH TOTALS ORDER BY item_id, price_sold, date ) r
-ON l.item_id = r.item_id
-ORDER BY ALL;
+ON l.item_id = r.item_id;
DROP TABLE t;
diff --git a/tests/queries/0_stateless/01763_filter_push_down_bugs.reference b/tests/queries/0_stateless/01763_filter_push_down_bugs.reference
index 229ac6eae09..19018a610b7 100644
--- a/tests/queries/0_stateless/01763_filter_push_down_bugs.reference
+++ b/tests/queries/0_stateless/01763_filter_push_down_bugs.reference
@@ -26,7 +26,7 @@ Expression ((Projection + Before ORDER BY))
Parts: 1/1
Granules: 1/1
Expression ((Project names + Projection))
- Filter (WHERE)
+ Filter ((WHERE + DROP unused columns after JOIN))
Join (JOIN FillRightFirst)
Expression
ReadFromMergeTree (default.t1)
diff --git a/tests/queries/0_stateless/01881_join_on_conditions_hash.sql.j2 b/tests/queries/0_stateless/01881_join_on_conditions_hash.sql.j2
index c13722f431a..c2d85cefb18 100644
--- a/tests/queries/0_stateless/01881_join_on_conditions_hash.sql.j2
+++ b/tests/queries/0_stateless/01881_join_on_conditions_hash.sql.j2
@@ -75,7 +75,7 @@ SELECT * FROM t1 INNER ALL JOIN t2 ON t1.id == t2.id AND t2.key; -- { serverErro
SELECT * FROM t1 JOIN t2_nullable as t2 ON t2.key == t2.key2 AND (t1.id == t2.id OR isNull(t2.key2)); -- { serverError 403 }
SELECT * FROM t1 JOIN t2 ON t2.key == t2.key2 OR t1.id == t2.id; -- { serverError 403 }
SELECT * FROM t1 JOIN t2 ON (t2.key == t2.key2 AND (t1.key == t1.key2 AND t1.key != 'XXX' OR t1.id == t2.id)) AND t1.id == t2.id; -- { serverError 403 }
-SELECT * FROM t1 JOIN t2 ON t2.key == t2.key2 AND t1.key == t1.key2 AND t1.key != 'XXX' AND t1.id == t2.id OR t2.key == t2.key2 AND t1.id == t2.id AND t1.id == t2.id ORDER BY ALL;
+SELECT * FROM t1 JOIN t2 ON t2.key == t2.key2 AND t1.key == t1.key2 AND t1.key != 'XXX' AND t1.id == t2.id OR t2.key == t2.key2 AND t1.id == t2.id AND t1.id == t2.id;
-- non-equi condition containing columns from different tables doesn't supported yet
SELECT * FROM t1 INNER ALL JOIN t2 ON t1.id == t2.id AND t1.id >= t2.id; -- { serverError 403 }
SELECT * FROM t1 INNER ANY JOIN t2 ON t1.id == t2.id AND t2.key == t2.key2 AND t1.key == t1.key2 AND t1.id >= length(t2.key); -- { serverError 403 }
@@ -89,10 +89,10 @@ SELECT 't22', * FROM t1 JOIN t22 ON t1.id == t22.idd and (t1.id == t22.id OR t22
SELECT 't22', * FROM t1 JOIN t22 ON (t22.key == t22.key2 OR t1.id == t22.id) and t1.id == t22.idd; -- { serverError 403 }
SELECT 't22', * FROM t1 JOIN t22 ON (t1.id == t22.id OR t22.key == t22.key2) and t1.id == t22.idd; -- { serverError 403 }
SELECT 't22', * FROM t1 JOIN t22 ON (t1.id == t22.id OR t22.key == t22.key2) and (t1.id == t22.idd AND (t1.key2 = 'a1' OR t1.key2 = 'a2' OR t1.key2 = 'a3' OR t1.key2 = 'a4' OR t1.key2 = 'a5' OR t1.key2 = 'a6' OR t1.key2 = 'a7' OR t1.key2 = 'a8' OR t1.key2 = 'a9' OR t1.key2 = 'a10' OR t1.key2 = 'a11' OR t1.key2 = 'a12' OR t1.key2 = 'a13' OR t1.key2 = 'a14' OR t1.key2 = 'a15' OR t1.key2 = 'a16' OR t1.key2 = 'a17' OR t1.key2 = 'a18' OR t1.key2 = 'a19' OR t1.key2 = '111')); -- { serverError 403 }
-SELECT 't22', * FROM t1 JOIN t22 ON t1.id == t22.idd and t22.key == t22.key2 OR t1.id == t22.idd and t1.id == t22.id ORDER BY ALL;
-SELECT 't22', * FROM t1 JOIN t22 ON t1.id == t22.idd and t1.id == t22.id OR t1.id == t22.idd and t22.key == t22.key2 ORDER BY ALL;
-SELECT 't22', * FROM t1 JOIN t22 ON t22.key == t22.key2 and t1.id == t22.idd OR t1.id == t22.id and t1.id == t22.idd ORDER BY ALL;
-SELECT 't22', * FROM t1 JOIN t22 ON t1.id == t22.id and t1.id == t22.idd OR t22.key == t22.key2 and t1.id == t22.idd ORDER BY ALL;
+SELECT 't22', * FROM t1 JOIN t22 ON t1.id == t22.idd and t22.key == t22.key2 OR t1.id == t22.idd and t1.id == t22.id;
+SELECT 't22', * FROM t1 JOIN t22 ON t1.id == t22.idd and t1.id == t22.id OR t1.id == t22.idd and t22.key == t22.key2;
+SELECT 't22', * FROM t1 JOIN t22 ON t22.key == t22.key2 and t1.id == t22.idd OR t1.id == t22.id and t1.id == t22.idd;
+SELECT 't22', * FROM t1 JOIN t22 ON t1.id == t22.id and t1.id == t22.idd OR t22.key == t22.key2 and t1.id == t22.idd;
{% endfor -%}
diff --git a/tests/queries/0_stateless/02000_join_on_const.reference b/tests/queries/0_stateless/02000_join_on_const.reference
index f8e46a2b976..3bd1633ce32 100644
--- a/tests/queries/0_stateless/02000_join_on_const.reference
+++ b/tests/queries/0_stateless/02000_join_on_const.reference
@@ -33,23 +33,23 @@
2 2
2 2
-- { echoOn }
-SELECT * FROM t1 LEFT JOIN t2 ON t1.id = t2.id AND 1 = 1 ORDER BY 1 SETTINGS enable_analyzer = 1;
+SELECT * FROM t1 LEFT JOIN t2 ON t1.id = t2.id AND 1 = 1 SETTINGS enable_analyzer = 1;
1 0
2 2
-SELECT * FROM t1 RIGHT JOIN t2 ON t1.id = t2.id AND 1 = 1 ORDER BY 1 SETTINGS enable_analyzer = 1;
-0 3
+SELECT * FROM t1 RIGHT JOIN t2 ON t1.id = t2.id AND 1 = 1 SETTINGS enable_analyzer = 1;
2 2
-SELECT * FROM t1 FULL JOIN t2 ON t1.id = t2.id AND 1 = 1 ORDER BY 2, 1 SETTINGS enable_analyzer = 1;
+0 3
+SELECT * FROM t1 FULL JOIN t2 ON t1.id = t2.id AND 1 = 1 SETTINGS enable_analyzer = 1;
1 0
2 2
0 3
-SELECT * FROM t1 LEFT JOIN t2 ON t1.id = t2.id AND 1 = 2 ORDER BY 1 SETTINGS enable_analyzer = 1;
+SELECT * FROM t1 LEFT JOIN t2 ON t1.id = t2.id AND 1 = 2 SETTINGS enable_analyzer = 1;
1 0
2 0
-SELECT * FROM t1 RIGHT JOIN t2 ON t1.id = t2.id AND 1 = 2 ORDER BY 2 SETTINGS enable_analyzer = 1;
+SELECT * FROM t1 RIGHT JOIN t2 ON t1.id = t2.id AND 1 = 2 SETTINGS enable_analyzer = 1;
0 2
0 3
-SELECT * FROM t1 FULL JOIN t2 ON t1.id = t2.id AND 1 = 2 ORDER BY 2, 1 SETTINGS enable_analyzer = 1;
+SELECT * FROM t1 FULL JOIN t2 ON t1.id = t2.id AND 1 = 2 SETTINGS enable_analyzer = 1;
1 0
2 0
0 2
@@ -59,11 +59,11 @@ SELECT * FROM (SELECT 1 as a) as t1 LEFT JOIN ( SELECT ('b', 256) as b ) AS t2
1 ('',0)
SELECT * FROM (SELECT 1 as a) as t1 RIGHT JOIN ( SELECT ('b', 256) as b ) AS t2 ON NULL;
0 ('b',256)
-SELECT * FROM (SELECT 1 as a) as t1 FULL JOIN ( SELECT ('b', 256) as b ) AS t2 ON NULL ORDER BY 2;
+SELECT * FROM (SELECT 1 as a) as t1 FULL JOIN ( SELECT ('b', 256) as b ) AS t2 ON NULL;
1 ('',0)
0 ('b',256)
SELECT * FROM (SELECT 1 as a) as t1 SEMI JOIN ( SELECT ('b', 256) as b ) AS t2 ON NULL;
-SELECT * FROM (SELECT 1 as a) as t1 ANTI JOIN ( SELECT ('b', 256) as b ) AS t2 ON NULL ORDER BY 2;
+SELECT * FROM (SELECT 1 as a) as t1 ANTI JOIN ( SELECT ('b', 256) as b ) AS t2 ON NULL;
1 ('',0)
2
4 2 Nullable(UInt64) UInt8
diff --git a/tests/queries/0_stateless/02000_join_on_const.sql b/tests/queries/0_stateless/02000_join_on_const.sql
index 33638edafa5..da70973ed87 100644
--- a/tests/queries/0_stateless/02000_join_on_const.sql
+++ b/tests/queries/0_stateless/02000_join_on_const.sql
@@ -73,20 +73,20 @@ SELECT * FROM t1 JOIN t2 ON t1.id = t2.id AND 1 SETTINGS enable_analyzer = 0; --
SELECT * FROM t1 JOIN t2 ON t1.id = t2.id AND 1 SETTINGS enable_analyzer = 1;
-- { echoOn }
-SELECT * FROM t1 LEFT JOIN t2 ON t1.id = t2.id AND 1 = 1 ORDER BY 1 SETTINGS enable_analyzer = 1;
-SELECT * FROM t1 RIGHT JOIN t2 ON t1.id = t2.id AND 1 = 1 ORDER BY 1 SETTINGS enable_analyzer = 1;
-SELECT * FROM t1 FULL JOIN t2 ON t1.id = t2.id AND 1 = 1 ORDER BY 2, 1 SETTINGS enable_analyzer = 1;
+SELECT * FROM t1 LEFT JOIN t2 ON t1.id = t2.id AND 1 = 1 SETTINGS enable_analyzer = 1;
+SELECT * FROM t1 RIGHT JOIN t2 ON t1.id = t2.id AND 1 = 1 SETTINGS enable_analyzer = 1;
+SELECT * FROM t1 FULL JOIN t2 ON t1.id = t2.id AND 1 = 1 SETTINGS enable_analyzer = 1;
-SELECT * FROM t1 LEFT JOIN t2 ON t1.id = t2.id AND 1 = 2 ORDER BY 1 SETTINGS enable_analyzer = 1;
-SELECT * FROM t1 RIGHT JOIN t2 ON t1.id = t2.id AND 1 = 2 ORDER BY 2 SETTINGS enable_analyzer = 1;
-SELECT * FROM t1 FULL JOIN t2 ON t1.id = t2.id AND 1 = 2 ORDER BY 2, 1 SETTINGS enable_analyzer = 1;
+SELECT * FROM t1 LEFT JOIN t2 ON t1.id = t2.id AND 1 = 2 SETTINGS enable_analyzer = 1;
+SELECT * FROM t1 RIGHT JOIN t2 ON t1.id = t2.id AND 1 = 2 SETTINGS enable_analyzer = 1;
+SELECT * FROM t1 FULL JOIN t2 ON t1.id = t2.id AND 1 = 2 SETTINGS enable_analyzer = 1;
SELECT * FROM (SELECT 1 as a) as t1 INNER JOIN ( SELECT ('b', 256) as b ) AS t2 ON NULL;
SELECT * FROM (SELECT 1 as a) as t1 LEFT JOIN ( SELECT ('b', 256) as b ) AS t2 ON NULL;
SELECT * FROM (SELECT 1 as a) as t1 RIGHT JOIN ( SELECT ('b', 256) as b ) AS t2 ON NULL;
-SELECT * FROM (SELECT 1 as a) as t1 FULL JOIN ( SELECT ('b', 256) as b ) AS t2 ON NULL ORDER BY 2;
+SELECT * FROM (SELECT 1 as a) as t1 FULL JOIN ( SELECT ('b', 256) as b ) AS t2 ON NULL;
SELECT * FROM (SELECT 1 as a) as t1 SEMI JOIN ( SELECT ('b', 256) as b ) AS t2 ON NULL;
-SELECT * FROM (SELECT 1 as a) as t1 ANTI JOIN ( SELECT ('b', 256) as b ) AS t2 ON NULL ORDER BY 2;
+SELECT * FROM (SELECT 1 as a) as t1 ANTI JOIN ( SELECT ('b', 256) as b ) AS t2 ON NULL;
-- { echoOff }
diff --git a/tests/queries/0_stateless/02001_join_on_const_bs_long.sql.j2 b/tests/queries/0_stateless/02001_join_on_const_bs_long.sql.j2
index 83548e087bd..1726bcb7062 100644
--- a/tests/queries/0_stateless/02001_join_on_const_bs_long.sql.j2
+++ b/tests/queries/0_stateless/02001_join_on_const_bs_long.sql.j2
@@ -1,8 +1,8 @@
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
-CREATE TABLE t1 (id Int) ENGINE = TinyLog;
-CREATE TABLE t2 (id Int) ENGINE = TinyLog;
+CREATE TABLE t1 (id Int) ENGINE = MergeTree ORDER BY id;
+CREATE TABLE t2 (id Int) ENGINE = MergeTree ORDER BY id;
INSERT INTO t1 VALUES (1), (2);
INSERT INTO t2 SELECT number + 5 AS x FROM (SELECT * FROM system.numbers LIMIT 1111);
diff --git a/tests/queries/0_stateless/02245_join_with_nullable_lowcardinality_crash.sql b/tests/queries/0_stateless/02245_join_with_nullable_lowcardinality_crash.sql
index c3c84ebaded..abc2ee41402 100644
--- a/tests/queries/0_stateless/02245_join_with_nullable_lowcardinality_crash.sql
+++ b/tests/queries/0_stateless/02245_join_with_nullable_lowcardinality_crash.sql
@@ -12,9 +12,8 @@ CREATE TABLE without_nullable
insert into with_nullable values(0,'f'),(0,'usa');
insert into without_nullable values(0,'usa'),(0,'us2a');
-select if(t0.country is null ,t2.country,t0.country) "country"
-from without_nullable t0 right outer join with_nullable t2 on t0.country=t2.country
-ORDER BY 1 DESC;
+select if(t0.country is null ,t2.country,t0.country) "country"
+from without_nullable t0 right outer join with_nullable t2 on t0.country=t2.country;
drop table with_nullable;
drop table without_nullable;
diff --git a/tests/queries/0_stateless/02282_array_distance.sql b/tests/queries/0_stateless/02282_array_distance.sql
index 85abc8fa381..2cca853fd67 100644
--- a/tests/queries/0_stateless/02282_array_distance.sql
+++ b/tests/queries/0_stateless/02282_array_distance.sql
@@ -48,8 +48,7 @@ SELECT
L2SquaredDistance(v1.v, v2.v),
cosineDistance(v1.v, v2.v)
FROM vec2 v1, vec2 v2
-WHERE length(v1.v) == length(v2.v)
-ORDER BY ALL;
+WHERE length(v1.v) == length(v2.v);
INSERT INTO vec2f VALUES (1, [100, 200, 0]), (2, [888, 777, 666]), (3, range(1, 35, 1)), (4, range(3, 37, 1)), (5, range(1, 135, 1)), (6, range(3, 137, 1));
SELECT
@@ -62,8 +61,7 @@ SELECT
L2SquaredDistance(v1.v, v2.v),
cosineDistance(v1.v, v2.v)
FROM vec2f v1, vec2f v2
-WHERE length(v1.v) == length(v2.v)
-ORDER BY ALL;
+WHERE length(v1.v) == length(v2.v);
INSERT INTO vec2d VALUES (1, [100, 200, 0]), (2, [888, 777, 666]), (3, range(1, 35, 1)), (4, range(3, 37, 1)), (5, range(1, 135, 1)), (6, range(3, 137, 1));
SELECT
@@ -76,8 +74,7 @@ SELECT
L2SquaredDistance(v1.v, v2.v),
cosineDistance(v1.v, v2.v)
FROM vec2d v1, vec2d v2
-WHERE length(v1.v) == length(v2.v)
-ORDER BY ALL;
+WHERE length(v1.v) == length(v2.v);
SELECT
v1.id,
@@ -89,8 +86,7 @@ SELECT
L2SquaredDistance(v1.v, v2.v),
cosineDistance(v1.v, v2.v)
FROM vec2f v1, vec2d v2
-WHERE length(v1.v) == length(v2.v)
-ORDER BY ALL;
+WHERE length(v1.v) == length(v2.v);
SELECT L1Distance([0, 0], [1]); -- { serverError SIZES_OF_ARRAYS_DONT_MATCH }
SELECT L2Distance([1, 2], (3,4)); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
diff --git a/tests/queries/0_stateless/02354_vector_search_multiple_indexes.reference b/tests/queries/0_stateless/02354_vector_search_bug_52282.reference
similarity index 100%
rename from tests/queries/0_stateless/02354_vector_search_multiple_indexes.reference
rename to tests/queries/0_stateless/02354_vector_search_bug_52282.reference
diff --git a/tests/queries/0_stateless/02354_vector_search_bug_52282.sql b/tests/queries/0_stateless/02354_vector_search_bug_52282.sql
new file mode 100644
index 00000000000..b8066ce278a
--- /dev/null
+++ b/tests/queries/0_stateless/02354_vector_search_bug_52282.sql
@@ -0,0 +1,13 @@
+-- Tags: no-fasttest, no-ordinary-database
+
+SET allow_experimental_vector_similarity_index = 1;
+
+-- Issue #52258: Vector similarity indexes must reject empty Arrays or Arrays with default values
+
+DROP TABLE IF EXISTS tab;
+
+CREATE TABLE tab (id UInt64, vec Array(Float32), INDEX idx vec TYPE vector_similarity('hnsw', 'L2Distance')) ENGINE = MergeTree() ORDER BY id;
+INSERT INTO tab VALUES (1, []); -- { serverError INCORRECT_DATA }
+INSERT INTO tab (id) VALUES (1); -- { serverError INCORRECT_DATA }
+
+DROP TABLE tab;
diff --git a/tests/queries/0_stateless/02354_vector_search_bugs.reference b/tests/queries/0_stateless/02354_vector_search_bug_69085.reference
similarity index 72%
rename from tests/queries/0_stateless/02354_vector_search_bugs.reference
rename to tests/queries/0_stateless/02354_vector_search_bug_69085.reference
index 9b610cf543a..3b4e2d9ef17 100644
--- a/tests/queries/0_stateless/02354_vector_search_bugs.reference
+++ b/tests/queries/0_stateless/02354_vector_search_bug_69085.reference
@@ -1,10 +1,3 @@
-Rejects INSERTs of Arrays with different sizes
-Issue #52258: Empty Arrays or Arrays with default values are rejected
-It is possible to create parts with different Array vector sizes but there will be an error at query time
-Correctness of index with > 1 mark
-1 [1,0] 0
-9000 [9000,0] 0
-Issue #69085: Reference vector computed by a subquery
Expression (Projection)
Limit (preliminary LIMIT (without OFFSET))
Sorting (Sorting for ORDER BY)
@@ -40,4 +33,3 @@ Expression (Projection)
Condition: true
Parts: 1/1
Granules: 4/4
-index_granularity_bytes = 0 is disallowed
diff --git a/tests/queries/0_stateless/02354_vector_search_bug_69085.sql b/tests/queries/0_stateless/02354_vector_search_bug_69085.sql
new file mode 100644
index 00000000000..4dbcdf66e36
--- /dev/null
+++ b/tests/queries/0_stateless/02354_vector_search_bug_69085.sql
@@ -0,0 +1,52 @@
+-- Tags: no-fasttest, no-ordinary-database
+
+SET allow_experimental_vector_similarity_index = 1;
+SET enable_analyzer = 0;
+
+-- Issue #69085: Reference vector for vector search is computed by a subquery
+
+DROP TABLE IF EXISTS tab;
+
+CREATE TABLE tab(id Int32, vec Array(Float32), INDEX idx vec TYPE vector_similarity('hnsw', 'cosineDistance', 'f16', 0, 0) GRANULARITY 2) ENGINE = MergeTree ORDER BY id SETTINGS index_granularity = 3;
+INSERT INTO tab VALUES (0, [4.6, 2.3]), (1, [2.0, 3.2]), (2, [4.2, 3.4]), (3, [5.3, 2.9]), (4, [2.4, 5.2]), (5, [5.3, 2.3]), (6, [1.0, 9.3]), (7, [5.5, 4.7]), (8, [6.4, 3.5]), (9, [5.3, 2.5]), (10, [6.4, 3.4]), (11, [6.4, 3.2]);
+
+-- works
+EXPLAIN indexes = 1
+WITH [0., 2.] AS reference_vec
+SELECT
+ id,
+ vec,
+ cosineDistance(vec, reference_vec) AS distance
+FROM tab
+ORDER BY distance
+LIMIT 1;
+
+-- does not work
+EXPLAIN indexes = 1
+WITH (
+ SELECT vec
+ FROM tab
+ LIMIT 1
+) AS reference_vec
+SELECT
+ id,
+ vec,
+ cosineDistance(vec, reference_vec) AS distance
+FROM tab
+ORDER BY distance
+LIMIT 1;
+
+-- does not work as well
+EXPLAIN indexes = 1
+WITH (
+ SELECT [0., 2.]
+) AS reference_vec
+SELECT
+ id,
+ vec,
+ cosineDistance(vec, reference_vec) AS distance
+FROM tab
+ORDER BY distance
+LIMIT 1;
+
+DROP TABLE tab;
diff --git a/tests/queries/0_stateless/02354_vector_search_bug_71381.reference b/tests/queries/0_stateless/02354_vector_search_bug_71381.reference
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/queries/0_stateless/02354_vector_search_bug_71381.sql b/tests/queries/0_stateless/02354_vector_search_bug_71381.sql
new file mode 100644
index 00000000000..9e3246700b8
--- /dev/null
+++ b/tests/queries/0_stateless/02354_vector_search_bug_71381.sql
@@ -0,0 +1,20 @@
+-- Tags: no-fasttest, no-ordinary-database
+
+SET allow_experimental_vector_similarity_index = 1;
+
+-- Issue #71381: Usage of vector similarity index and further skipping indexes on the same table
+
+DROP TABLE IF EXISTS tab;
+
+CREATE TABLE tab(
+ val String,
+ vec Array(Float32),
+ INDEX ann_idx vec TYPE vector_similarity('hnsw', 'cosineDistance'),
+ INDEX set_idx val TYPE set(100)
+)
+ENGINE = MergeTree()
+ORDER BY tuple();
+
+INSERT INTO tab VALUES ('hello world', [0.0]);
+
+DROP TABLE tab;
diff --git a/tests/queries/0_stateless/02354_vector_search_bug_adaptive_index_granularity.reference b/tests/queries/0_stateless/02354_vector_search_bug_adaptive_index_granularity.reference
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/queries/0_stateless/02354_vector_search_bug_adaptive_index_granularity.sql b/tests/queries/0_stateless/02354_vector_search_bug_adaptive_index_granularity.sql
new file mode 100644
index 00000000000..208b5b7a874
--- /dev/null
+++ b/tests/queries/0_stateless/02354_vector_search_bug_adaptive_index_granularity.sql
@@ -0,0 +1,20 @@
+-- Tags: no-fasttest, no-ordinary-database
+
+-- Tests that vector similarity indexes cannot be created with index_granularity_bytes = 0
+
+SET allow_experimental_vector_similarity_index = 1;
+
+DROP TABLE IF EXISTS tab;
+
+-- If adaptive index granularity is disabled, certain vector search queries with PREWHERE run into LOGICAL_ERRORs.
+-- SET allow_experimental_vector_similarity_index = 1;
+-- CREATE TABLE tab (`id` Int32, `vec` Array(Float32), INDEX idx vec TYPE vector_similarity('hnsw', 'L2Distance') GRANULARITY 100000000) ENGINE = MergeTree ORDER BY id SETTINGS index_granularity_bytes = 0;
+-- INSERT INTO tab SELECT number, [toFloat32(number), 0.] FROM numbers(10000);
+-- WITH [1., 0.] AS reference_vec SELECT id, L2Distance(vec, reference_vec) FROM tab PREWHERE toLowCardinality(10) ORDER BY L2Distance(vec, reference_vec) ASC LIMIT 100;
+-- As a workaround, force enabled adaptive index granularity for now (it is the default anyways).
+CREATE TABLE tab(id Int32, vec Array(Float32), INDEX idx vec TYPE vector_similarity('hnsw', 'L2Distance')) ENGINE = MergeTree ORDER BY id SETTINGS index_granularity_bytes = 0; -- { serverError INVALID_SETTING_VALUE }
+
+CREATE TABLE tab(id Int32, vec Array(Float32)) ENGINE = MergeTree ORDER BY id SETTINGS index_granularity_bytes = 0;
+ALTER TABLE tab ADD INDEX vec_idx1(vec) TYPE vector_similarity('hnsw', 'cosineDistance'); -- { serverError INVALID_SETTING_VALUE }
+
+DROP TABLE tab;
diff --git a/tests/queries/0_stateless/02354_vector_search_bug_different_array_sizes.reference b/tests/queries/0_stateless/02354_vector_search_bug_different_array_sizes.reference
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/queries/0_stateless/02354_vector_search_bug_different_array_sizes.sql b/tests/queries/0_stateless/02354_vector_search_bug_different_array_sizes.sql
new file mode 100644
index 00000000000..41b9d7869e4
--- /dev/null
+++ b/tests/queries/0_stateless/02354_vector_search_bug_different_array_sizes.sql
@@ -0,0 +1,24 @@
+-- Tags: no-fasttest, no-ordinary-database
+
+SET allow_experimental_vector_similarity_index = 1;
+SET enable_analyzer = 1; -- 0 vs. 1 produce slightly different error codes, make it future-proof
+
+DROP TABLE IF EXISTS tab;
+
+CREATE TABLE tab(id Int32, vec Array(Float32), INDEX idx vec TYPE vector_similarity('hnsw', 'L2Distance')) ENGINE = MergeTree ORDER BY id;
+
+-- Vector similarity indexes reject INSERTs of Arrays with different sizes
+INSERT INTO tab values (0, [2.2, 2.3]) (1, [3.1, 3.2, 3.3]); -- { serverError INCORRECT_DATA }
+
+-- It is possible to create parts with different Array vector sizes but there will be an error at query time
+SYSTEM STOP MERGES tab;
+INSERT INTO tab values (0, [2.2, 2.3]) (1, [3.1, 3.2]);
+INSERT INTO tab values (2, [2.2, 2.3, 2.4]) (3, [3.1, 3.2, 3.3]);
+
+WITH [0.0, 2.0] AS reference_vec
+SELECT id, vec, L2Distance(vec, reference_vec)
+FROM tab
+ORDER BY L2Distance(vec, reference_vec)
+LIMIT 3; -- { serverError SIZES_OF_ARRAYS_DONT_MATCH }
+
+DROP TABLE tab;
diff --git a/tests/queries/0_stateless/02354_vector_search_bug_multiple_indexes.reference b/tests/queries/0_stateless/02354_vector_search_bug_multiple_indexes.reference
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/queries/0_stateless/02354_vector_search_multiple_indexes.sql b/tests/queries/0_stateless/02354_vector_search_bug_multiple_indexes.sql
similarity index 100%
rename from tests/queries/0_stateless/02354_vector_search_multiple_indexes.sql
rename to tests/queries/0_stateless/02354_vector_search_bug_multiple_indexes.sql
diff --git a/tests/queries/0_stateless/02354_vector_search_bug_multiple_marks.reference b/tests/queries/0_stateless/02354_vector_search_bug_multiple_marks.reference
new file mode 100644
index 00000000000..117bf2cead8
--- /dev/null
+++ b/tests/queries/0_stateless/02354_vector_search_bug_multiple_marks.reference
@@ -0,0 +1,2 @@
+1 [1,0] 0
+9000 [9000,0] 0
diff --git a/tests/queries/0_stateless/02354_vector_search_bug_multiple_marks.sql b/tests/queries/0_stateless/02354_vector_search_bug_multiple_marks.sql
new file mode 100644
index 00000000000..fb99dd2361c
--- /dev/null
+++ b/tests/queries/0_stateless/02354_vector_search_bug_multiple_marks.sql
@@ -0,0 +1,25 @@
+-- Tags: no-fasttest, no-ordinary-database
+
+-- Tests correctness of vector similarity index with > 1 mark
+
+SET allow_experimental_vector_similarity_index = 1;
+SET enable_analyzer = 0;
+
+DROP TABLE IF EXISTS tab;
+
+CREATE TABLE tab(id Int32, vec Array(Float32), INDEX idx vec TYPE vector_similarity('hnsw', 'L2Distance')) ENGINE = MergeTree ORDER BY id SETTINGS index_granularity = 8192;
+INSERT INTO tab SELECT number, [toFloat32(number), 0.0] from numbers(10000);
+
+WITH [1.0, 0.0] AS reference_vec
+SELECT id, vec, L2Distance(vec, reference_vec)
+FROM tab
+ORDER BY L2Distance(vec, reference_vec)
+LIMIT 1;
+
+WITH [9000.0, 0.0] AS reference_vec
+SELECT id, vec, L2Distance(vec, reference_vec)
+FROM tab
+ORDER BY L2Distance(vec, reference_vec)
+LIMIT 1;
+
+DROP TABLE tab;
diff --git a/tests/queries/0_stateless/02354_vector_search_bugs.sql b/tests/queries/0_stateless/02354_vector_search_bugs.sql
deleted file mode 100644
index d55bdb88a76..00000000000
--- a/tests/queries/0_stateless/02354_vector_search_bugs.sql
+++ /dev/null
@@ -1,119 +0,0 @@
--- Tags: no-fasttest, no-ordinary-database
-
--- Tests various bugs and special cases for vector indexes.
-
-SET allow_experimental_vector_similarity_index = 1;
-SET enable_analyzer = 1; -- 0 vs. 1 produce slightly different error codes, make it future-proof
-
-DROP TABLE IF EXISTS tab;
-
-SELECT 'Rejects INSERTs of Arrays with different sizes';
-
-CREATE TABLE tab(id Int32, vec Array(Float32), INDEX idx vec TYPE vector_similarity('hnsw', 'L2Distance')) ENGINE = MergeTree ORDER BY id;
-INSERT INTO tab values (0, [2.2, 2.3]) (1, [3.1, 3.2, 3.3]); -- { serverError INCORRECT_DATA }
-DROP TABLE tab;
-
-SELECT 'Issue #52258: Empty Arrays or Arrays with default values are rejected';
-
-CREATE TABLE tab (id UInt64, vec Array(Float32), INDEX idx vec TYPE vector_similarity('hnsw', 'L2Distance')) ENGINE = MergeTree() ORDER BY id;
-INSERT INTO tab VALUES (1, []); -- { serverError INCORRECT_DATA }
-INSERT INTO tab (id) VALUES (1); -- { serverError INCORRECT_DATA }
-DROP TABLE tab;
-
-SELECT 'It is possible to create parts with different Array vector sizes but there will be an error at query time';
-
-CREATE TABLE tab(id Int32, vec Array(Float32), INDEX idx vec TYPE vector_similarity('hnsw', 'L2Distance')) ENGINE = MergeTree ORDER BY id;
-SYSTEM STOP MERGES tab;
-INSERT INTO tab values (0, [2.2, 2.3]) (1, [3.1, 3.2]);
-INSERT INTO tab values (2, [2.2, 2.3, 2.4]) (3, [3.1, 3.2, 3.3]);
-
-WITH [0.0, 2.0] AS reference_vec
-SELECT id, vec, L2Distance(vec, reference_vec)
-FROM tab
-ORDER BY L2Distance(vec, reference_vec)
-LIMIT 3; -- { serverError SIZES_OF_ARRAYS_DONT_MATCH }
-
-DROP TABLE tab;
-
-SELECT 'Correctness of index with > 1 mark';
-
-CREATE TABLE tab(id Int32, vec Array(Float32), INDEX idx vec TYPE vector_similarity('hnsw', 'L2Distance')) ENGINE = MergeTree ORDER BY id SETTINGS index_granularity = 8192;
-INSERT INTO tab SELECT number, [toFloat32(number), 0.0] from numbers(10000);
-
-WITH [1.0, 0.0] AS reference_vec
-SELECT id, vec, L2Distance(vec, reference_vec)
-FROM tab
-ORDER BY L2Distance(vec, reference_vec)
-LIMIT 1;
-
-WITH [9000.0, 0.0] AS reference_vec
-SELECT id, vec, L2Distance(vec, reference_vec)
-FROM tab
-ORDER BY L2Distance(vec, reference_vec)
-LIMIT 1;
-
-DROP TABLE tab;
-
-SELECT 'Issue #69085: Reference vector computed by a subquery';
-
-CREATE TABLE tab(id Int32, vec Array(Float32), INDEX idx vec TYPE vector_similarity('hnsw', 'cosineDistance', 'f16', 0, 0) GRANULARITY 2) ENGINE = MergeTree ORDER BY id SETTINGS index_granularity = 3;
-INSERT INTO tab VALUES (0, [4.6, 2.3]), (1, [2.0, 3.2]), (2, [4.2, 3.4]), (3, [5.3, 2.9]), (4, [2.4, 5.2]), (5, [5.3, 2.3]), (6, [1.0, 9.3]), (7, [5.5, 4.7]), (8, [6.4, 3.5]), (9, [5.3, 2.5]), (10, [6.4, 3.4]), (11, [6.4, 3.2]);
-
--- works
-EXPLAIN indexes = 1
-WITH [0., 2.] AS reference_vec
-SELECT
- id,
- vec,
- cosineDistance(vec, reference_vec) AS distance
-FROM tab
-ORDER BY distance
-LIMIT 1
-SETTINGS enable_analyzer = 0;
-
--- does not work
-EXPLAIN indexes = 1
-WITH (
- SELECT vec
- FROM tab
- LIMIT 1
-) AS reference_vec
-SELECT
- id,
- vec,
- cosineDistance(vec, reference_vec) AS distance
-FROM tab
-ORDER BY distance
-LIMIT 1
-SETTINGS enable_analyzer = 0;
-
--- does not work as well
-EXPLAIN indexes = 1
-WITH (
- SELECT [0., 2.]
-) AS reference_vec
-SELECT
- id,
- vec,
- cosineDistance(vec, reference_vec) AS distance
-FROM tab
-ORDER BY distance
-LIMIT 1
-SETTINGS enable_analyzer = 0;
-
-DROP TABLE tab;
-
-SELECT 'index_granularity_bytes = 0 is disallowed';
-
--- If adaptive index granularity is disabled, certain vector search queries with PREWHERE run into LOGICAL_ERRORs.
--- SET allow_experimental_vector_similarity_index = 1;
--- CREATE TABLE tab (`id` Int32, `vec` Array(Float32), INDEX idx vec TYPE vector_similarity('hnsw', 'L2Distance') GRANULARITY 100000000) ENGINE = MergeTree ORDER BY id SETTINGS index_granularity_bytes = 0;
--- INSERT INTO tab SELECT number, [toFloat32(number), 0.] FROM numbers(10000);
--- WITH [1., 0.] AS reference_vec SELECT id, L2Distance(vec, reference_vec) FROM tab PREWHERE toLowCardinality(10) ORDER BY L2Distance(vec, reference_vec) ASC LIMIT 100;
--- As a workaround, force enabled adaptive index granularity for now (it is the default anyways).
-CREATE TABLE tab(id Int32, vec Array(Float32), INDEX idx vec TYPE vector_similarity('hnsw', 'L2Distance')) ENGINE = MergeTree ORDER BY id SETTINGS index_granularity_bytes = 0; -- { serverError INVALID_SETTING_VALUE }
-
-CREATE TABLE tab(id Int32, vec Array(Float32)) ENGINE = MergeTree ORDER BY id SETTINGS index_granularity_bytes = 0;
-ALTER TABLE tab ADD INDEX vec_idx1(vec) TYPE vector_similarity('hnsw', 'cosineDistance'); -- { serverError INVALID_SETTING_VALUE }
-
-DROP TABLE tab;
diff --git a/tests/queries/0_stateless/02381_join_dup_columns_in_plan.reference b/tests/queries/0_stateless/02381_join_dup_columns_in_plan.reference
index 90aab0a0eb2..365725f8ffe 100644
--- a/tests/queries/0_stateless/02381_join_dup_columns_in_plan.reference
+++ b/tests/queries/0_stateless/02381_join_dup_columns_in_plan.reference
@@ -148,6 +148,7 @@ Header: key String
value String
Join
Header: __table1.key String
+ __table3.key String
__table3.value String
Sorting
Header: __table1.key String
diff --git a/tests/queries/0_stateless/02461_join_lc_issue_42380.sql b/tests/queries/0_stateless/02461_join_lc_issue_42380.sql
index 8b5c6846bd0..f0ecbf64e58 100644
--- a/tests/queries/0_stateless/02461_join_lc_issue_42380.sql
+++ b/tests/queries/0_stateless/02461_join_lc_issue_42380.sql
@@ -9,5 +9,4 @@ CREATE TABLE t2__fuzz_47 (id LowCardinality(Int16)) ENGINE = MergeTree() ORDER B
INSERT INTO t1__fuzz_13 VALUES (1);
INSERT INTO t2__fuzz_47 VALUES (1);
-SELECT * FROM t1__fuzz_13 FULL OUTER JOIN t2__fuzz_47 ON 1 = 2
-ORDER BY ALL;
+SELECT * FROM t1__fuzz_13 FULL OUTER JOIN t2__fuzz_47 ON 1 = 2;
diff --git a/tests/queries/0_stateless/02496_remove_redundant_sorting_analyzer.reference b/tests/queries/0_stateless/02496_remove_redundant_sorting_analyzer.reference
index c9bf36f88ea..3c68d14fdf2 100644
--- a/tests/queries/0_stateless/02496_remove_redundant_sorting_analyzer.reference
+++ b/tests/queries/0_stateless/02496_remove_redundant_sorting_analyzer.reference
@@ -117,7 +117,7 @@ ORDER BY t1.number, t2.number
-- explain
Expression (Project names)
Sorting (Sorting for ORDER BY)
- Expression ((Before ORDER BY + Projection))
+ Expression ((Before ORDER BY + (Projection + DROP unused columns after JOIN)))
Join (JOIN FillRightFirst)
Expression ((Change column names to column identifiers + (Project names + (Before ORDER BY + (Projection + (Change column names to column identifiers + (Project names + (Before ORDER BY + (Projection + Change column names to column identifiers)))))))))
ReadFromSystemNumbers
@@ -161,7 +161,7 @@ ORDER BY t1.number, t2.number
-- explain
Expression (Project names)
Sorting (Sorting for ORDER BY)
- Expression ((Before ORDER BY + Projection))
+ Expression ((Before ORDER BY + (Projection + DROP unused columns after JOIN)))
Join (JOIN FillRightFirst)
Expression ((Change column names to column identifiers + (Project names + (Before ORDER BY + (Projection + (Change column names to column identifiers + (Project names + (Before ORDER BY + (Projection + Change column names to column identifiers)))))))))
ReadFromSystemNumbers
diff --git a/tests/queries/0_stateless/02500_remove_redundant_distinct_analyzer.reference b/tests/queries/0_stateless/02500_remove_redundant_distinct_analyzer.reference
index baa2be9dfdb..867ae394c1f 100644
--- a/tests/queries/0_stateless/02500_remove_redundant_distinct_analyzer.reference
+++ b/tests/queries/0_stateless/02500_remove_redundant_distinct_analyzer.reference
@@ -79,7 +79,7 @@ Expression (Project names)
Sorting (Sorting for ORDER BY)
Expression (Before ORDER BY)
Distinct (Preliminary DISTINCT)
- Expression (Projection)
+ Expression ((Projection + DROP unused columns after JOIN))
Join (JOIN FillRightFirst)
Expression ((Change column names to column identifiers + Project names))
Distinct (DISTINCT)
@@ -244,7 +244,7 @@ Expression ((Project names + (Projection + (Change column names to column identi
Sorting (Sorting for ORDER BY)
Expression ((Before ORDER BY + Projection))
Aggregating
- Expression ((Before GROUP BY + (Change column names to column identifiers + (Project names + Projection))))
+ Expression ((Before GROUP BY + (Change column names to column identifiers + (Project names + (Projection + DROP unused columns after JOIN)))))
Join (JOIN FillRightFirst)
Expression (Change column names to column identifiers)
ReadFromSystemNumbers
@@ -280,7 +280,7 @@ Expression (Project names)
Sorting (Sorting for ORDER BY)
Expression ((Before ORDER BY + Projection))
Aggregating
- Expression ((Before GROUP BY + (Change column names to column identifiers + (Project names + Projection))))
+ Expression ((Before GROUP BY + (Change column names to column identifiers + (Project names + (Projection + DROP unused columns after JOIN)))))
Join (JOIN FillRightFirst)
Expression (Change column names to column identifiers)
ReadFromSystemNumbers
@@ -315,7 +315,7 @@ Expression (Project names)
Expression ((Before ORDER BY + Projection))
Rollup
Aggregating
- Expression ((Before GROUP BY + (Change column names to column identifiers + (Project names + Projection))))
+ Expression ((Before GROUP BY + (Change column names to column identifiers + (Project names + (Projection + DROP unused columns after JOIN)))))
Join (JOIN FillRightFirst)
Expression (Change column names to column identifiers)
ReadFromSystemNumbers
@@ -348,7 +348,7 @@ Expression ((Project names + (Projection + (Change column names to column identi
Expression ((Before ORDER BY + Projection))
Rollup
Aggregating
- Expression ((Before GROUP BY + (Change column names to column identifiers + (Project names + Projection))))
+ Expression ((Before GROUP BY + (Change column names to column identifiers + (Project names + (Projection + DROP unused columns after JOIN)))))
Join (JOIN FillRightFirst)
Expression (Change column names to column identifiers)
ReadFromSystemNumbers
@@ -386,7 +386,7 @@ Expression (Project names)
Expression ((Before ORDER BY + Projection))
Cube
Aggregating
- Expression ((Before GROUP BY + (Change column names to column identifiers + (Project names + Projection))))
+ Expression ((Before GROUP BY + (Change column names to column identifiers + (Project names + (Projection + DROP unused columns after JOIN)))))
Join (JOIN FillRightFirst)
Expression (Change column names to column identifiers)
ReadFromSystemNumbers
@@ -419,7 +419,7 @@ Expression ((Project names + (Projection + (Change column names to column identi
Expression ((Before ORDER BY + Projection))
Cube
Aggregating
- Expression ((Before GROUP BY + (Change column names to column identifiers + (Project names + Projection))))
+ Expression ((Before GROUP BY + (Change column names to column identifiers + (Project names + (Projection + DROP unused columns after JOIN)))))
Join (JOIN FillRightFirst)
Expression (Change column names to column identifiers)
ReadFromSystemNumbers
@@ -457,7 +457,7 @@ Expression (Project names)
Expression ((Before ORDER BY + Projection))
TotalsHaving
Aggregating
- Expression ((Before GROUP BY + (Change column names to column identifiers + (Project names + Projection))))
+ Expression ((Before GROUP BY + (Change column names to column identifiers + (Project names + (Projection + DROP unused columns after JOIN)))))
Join (JOIN FillRightFirst)
Expression (Change column names to column identifiers)
ReadFromSystemNumbers
@@ -491,7 +491,7 @@ Expression ((Project names + (Projection + (Change column names to column identi
Expression ((Before ORDER BY + Projection))
TotalsHaving
Aggregating
- Expression ((Before GROUP BY + (Change column names to column identifiers + (Project names + Projection))))
+ Expression ((Before GROUP BY + (Change column names to column identifiers + (Project names + (Projection + DROP unused columns after JOIN)))))
Join (JOIN FillRightFirst)
Expression (Change column names to column identifiers)
ReadFromSystemNumbers
diff --git a/tests/queries/0_stateless/02514_analyzer_drop_join_on.reference b/tests/queries/0_stateless/02514_analyzer_drop_join_on.reference
index bbfdf1ad5f4..2c62e278050 100644
--- a/tests/queries/0_stateless/02514_analyzer_drop_join_on.reference
+++ b/tests/queries/0_stateless/02514_analyzer_drop_join_on.reference
@@ -8,21 +8,24 @@ Header: count() UInt64
Aggregating
Header: __table1.a2 String
count() UInt64
- Expression (Before GROUP BY)
+ Expression ((Before GROUP BY + DROP unused columns after JOIN))
Header: __table1.a2 String
Join (JOIN FillRightFirst)
Header: __table1.a2 String
- Expression (JOIN actions)
+ __table3.c1 UInt64
+ Expression ((JOIN actions + DROP unused columns after JOIN))
Header: __table1.a2 String
__table3.c1 UInt64
Join (JOIN FillRightFirst)
Header: __table1.a2 String
+ __table2.b1 UInt64
__table3.c1 UInt64
- Expression (JOIN actions)
+ Expression ((JOIN actions + DROP unused columns after JOIN))
Header: __table1.a2 String
__table2.b1 UInt64
Join (JOIN FillRightFirst)
- Header: __table1.a2 String
+ Header: __table1.a1 UInt64
+ __table1.a2 String
__table2.b1 UInt64
Expression ((JOIN actions + Change column names to column identifiers))
Header: __table1.a1 UInt64
@@ -45,32 +48,39 @@ Header: count() UInt64
EXPLAIN PLAN header = 1
SELECT a.a2, d.d2 FROM a JOIN b USING (k) JOIN c USING (k) JOIN d USING (k)
;
-Expression ((Project names + Projection))
+Expression ((Project names + (Projection + DROP unused columns after JOIN)))
Header: a2 String
d2 String
Join (JOIN FillRightFirst)
Header: __table1.a2 String
+ __table1.k UInt64
__table4.d2 String
- Join (JOIN FillRightFirst)
+ Expression (DROP unused columns after JOIN)
Header: __table1.a2 String
__table1.k UInt64
Join (JOIN FillRightFirst)
Header: __table1.a2 String
__table1.k UInt64
- Expression (Change column names to column identifiers)
+ Expression (DROP unused columns after JOIN)
Header: __table1.a2 String
__table1.k UInt64
- ReadFromMemoryStorage
- Header: a2 String
- k UInt64
+ Join (JOIN FillRightFirst)
+ Header: __table1.a2 String
+ __table1.k UInt64
+ Expression (Change column names to column identifiers)
+ Header: __table1.a2 String
+ __table1.k UInt64
+ ReadFromMemoryStorage
+ Header: a2 String
+ k UInt64
+ Expression (Change column names to column identifiers)
+ Header: __table2.k UInt64
+ ReadFromMemoryStorage
+ Header: k UInt64
Expression (Change column names to column identifiers)
- Header: __table2.k UInt64
+ Header: __table3.k UInt64
ReadFromMemoryStorage
Header: k UInt64
- Expression (Change column names to column identifiers)
- Header: __table3.k UInt64
- ReadFromMemoryStorage
- Header: k UInt64
Expression (Change column names to column identifiers)
Header: __table4.d2 String
__table4.k UInt64
@@ -96,24 +106,27 @@ Header: bx String
Header: __table1.a2 String
__table2.bx String
__table4.c2 String
+ __table4.c1 UInt64
Expression
Header: __table1.a2 String
__table2.bx String
- __table4.c1 UInt64
__table4.c2 String
+ __table4.c1 UInt64
Join (JOIN FillRightFirst)
Header: __table1.a2 String
__table2.bx String
- __table4.c1 UInt64
+ __table2.b1 UInt64
__table4.c2 String
- Expression (JOIN actions)
+ __table4.c1 UInt64
+ Expression ((JOIN actions + DROP unused columns after JOIN))
Header: __table1.a2 String
- __table2.b1 UInt64
__table2.bx String
+ __table2.b1 UInt64
Join (JOIN FillRightFirst)
- Header: __table1.a2 String
- __table2.b1 UInt64
+ Header: __table1.a1 UInt64
+ __table1.a2 String
__table2.bx String
+ __table2.b1 UInt64
Expression ((JOIN actions + Change column names to column identifiers))
Header: __table1.a1 UInt64
__table1.a2 String
diff --git a/tests/queries/0_stateless/02514_analyzer_drop_join_on.sql b/tests/queries/0_stateless/02514_analyzer_drop_join_on.sql
index b10bf38e495..df84e2f50b2 100644
--- a/tests/queries/0_stateless/02514_analyzer_drop_join_on.sql
+++ b/tests/queries/0_stateless/02514_analyzer_drop_join_on.sql
@@ -16,7 +16,6 @@ CREATE TABLE d (k UInt64, d1 UInt64, d2 String) ENGINE = Memory;
INSERT INTO d VALUES (1, 1, 'a'), (2, 2, 'b'), (3, 3, 'c');
SET enable_analyzer = 1;
-SET query_plan_join_inner_table_selection = 'right';
-- { echoOn }
diff --git a/tests/queries/0_stateless/02516_join_with_totals_and_subquery_bug.reference b/tests/queries/0_stateless/02516_join_with_totals_and_subquery_bug.reference
index 116c78a15e4..86e7e2a6a49 100644
--- a/tests/queries/0_stateless/02516_join_with_totals_and_subquery_bug.reference
+++ b/tests/queries/0_stateless/02516_join_with_totals_and_subquery_bug.reference
@@ -5,7 +5,7 @@
1
1
-0
+1
\N
100000000000000000000
diff --git a/tests/queries/0_stateless/02835_join_step_explain.reference b/tests/queries/0_stateless/02835_join_step_explain.reference
index bdbc019d4f8..06f4a9cfc99 100644
--- a/tests/queries/0_stateless/02835_join_step_explain.reference
+++ b/tests/queries/0_stateless/02835_join_step_explain.reference
@@ -1,22 +1,22 @@
-Expression ((Project names + Projection))
+Expression ((Project names + (Projection + DROP unused columns after JOIN)))
Header: id UInt64
value_1 String
rhs.id UInt64
rhs.value_1 String
Actions: INPUT : 0 -> __table1.id UInt64 : 0
INPUT : 1 -> __table1.value_1 String : 1
- INPUT : 2 -> __table2.id UInt64 : 2
- INPUT : 3 -> __table2.value_1 String : 3
+ INPUT : 2 -> __table2.value_1 String : 2
+ INPUT : 3 -> __table2.id UInt64 : 3
ALIAS __table1.id :: 0 -> id UInt64 : 4
ALIAS __table1.value_1 :: 1 -> value_1 String : 0
- ALIAS __table2.id :: 2 -> rhs.id UInt64 : 1
- ALIAS __table2.value_1 :: 3 -> rhs.value_1 String : 2
-Positions: 4 0 1 2
+ ALIAS __table2.value_1 :: 2 -> rhs.value_1 String : 1
+ ALIAS __table2.id :: 3 -> rhs.id UInt64 : 2
+Positions: 4 0 2 1
Join (JOIN FillRightFirst)
Header: __table1.id UInt64
__table1.value_1 String
- __table2.id UInt64
__table2.value_1 String
+ __table2.id UInt64
Type: INNER
Strictness: ALL
Algorithm: HashJoin
@@ -50,25 +50,29 @@ Positions: 4 0 1 2
Parts: 1
Granules: 1
--
-Expression ((Project names + Projection))
+Expression ((Project names + (Projection + DROP unused columns after JOIN)))
Header: id UInt64
value_1 String
rhs.id UInt64
rhs.value_1 String
Actions: INPUT : 0 -> __table1.id UInt64 : 0
INPUT : 1 -> __table1.value_1 String : 1
- INPUT : 2 -> __table2.id UInt64 : 2
+ INPUT :: 2 -> __table1.value_2 UInt64 : 2
INPUT : 3 -> __table2.value_1 String : 3
- ALIAS __table1.id :: 0 -> id UInt64 : 4
+ INPUT :: 4 -> __table2.value_2 UInt64 : 4
+ INPUT : 5 -> __table2.id UInt64 : 5
+ ALIAS __table1.id :: 0 -> id UInt64 : 6
ALIAS __table1.value_1 :: 1 -> value_1 String : 0
- ALIAS __table2.id :: 2 -> rhs.id UInt64 : 1
- ALIAS __table2.value_1 :: 3 -> rhs.value_1 String : 2
-Positions: 4 0 1 2
+ ALIAS __table2.value_1 :: 3 -> rhs.value_1 String : 1
+ ALIAS __table2.id :: 5 -> rhs.id UInt64 : 3
+Positions: 6 0 3 1
Join (JOIN FillRightFirst)
Header: __table1.id UInt64
__table1.value_1 String
- __table2.id UInt64
+ __table1.value_2 UInt64
__table2.value_1 String
+ __table2.value_2 UInt64
+ __table2.id UInt64
Type: INNER
Strictness: ASOF
Algorithm: HashJoin
diff --git a/tests/queries/0_stateless/02835_join_step_explain.sql b/tests/queries/0_stateless/02835_join_step_explain.sql
index b803ddbd911..1cdd3684a0b 100644
--- a/tests/queries/0_stateless/02835_join_step_explain.sql
+++ b/tests/queries/0_stateless/02835_join_step_explain.sql
@@ -19,8 +19,6 @@ CREATE TABLE test_table_2
INSERT INTO test_table_1 VALUES (0, 'Value', 0);
INSERT INTO test_table_2 VALUES (0, 'Value', 0);
-SET query_plan_join_inner_table_selection = 'right';
-
EXPLAIN header = 1, actions = 1 SELECT lhs.id, lhs.value_1, rhs.id, rhs.value_1
FROM test_table_1 AS lhs INNER JOIN test_table_2 AS rhs ON lhs.id = rhs.id;
diff --git a/tests/queries/0_stateless/02962_join_using_bug_57894.reference b/tests/queries/0_stateless/02962_join_using_bug_57894.reference
index fc6fe462205..454655081df 100644
--- a/tests/queries/0_stateless/02962_join_using_bug_57894.reference
+++ b/tests/queries/0_stateless/02962_join_using_bug_57894.reference
@@ -31,7 +31,6 @@
8
9
\N
---- analyzer ---
0
1
2
diff --git a/tests/queries/0_stateless/02962_join_using_bug_57894.sql b/tests/queries/0_stateless/02962_join_using_bug_57894.sql
index e29347beb5e..96190241da5 100644
--- a/tests/queries/0_stateless/02962_join_using_bug_57894.sql
+++ b/tests/queries/0_stateless/02962_join_using_bug_57894.sql
@@ -21,8 +21,6 @@ SETTINGS join_algorithm = 'partial_merge';
SELECT x FROM t FULL JOIN r USING (x) ORDER BY ALL
SETTINGS join_algorithm = 'full_sorting_merge';
-SELECT '--- analyzer ---';
-
SET enable_analyzer = 1;
SELECT x FROM t FULL JOIN r USING (x) ORDER BY ALL
diff --git a/tests/queries/0_stateless/03036_join_filter_push_down_equivalent_sets.reference b/tests/queries/0_stateless/03036_join_filter_push_down_equivalent_sets.reference
index b7718d926c6..80f4e309505 100644
--- a/tests/queries/0_stateless/03036_join_filter_push_down_equivalent_sets.reference
+++ b/tests/queries/0_stateless/03036_join_filter_push_down_equivalent_sets.reference
@@ -2,9 +2,7 @@
EXPLAIN header = 1, actions = 1
SELECT lhs.id, rhs.id, lhs.value, rhs.value FROM test_table_1 AS lhs INNER JOIN test_table_2 AS rhs ON lhs.id = rhs.id
-WHERE lhs.id = 5
-SETTINGS query_plan_join_inner_table_selection = 'right'
-;
+WHERE lhs.id = 5;
Expression ((Project names + (Projection + )))
Header: id UInt64
rhs.id UInt64
@@ -12,18 +10,18 @@ Header: id UInt64
rhs.value String
Actions: INPUT : 0 -> __table1.id UInt64 : 0
INPUT : 1 -> __table1.value String : 1
- INPUT : 2 -> __table2.id UInt64 : 2
- INPUT : 3 -> __table2.value String : 3
+ INPUT : 2 -> __table2.value String : 2
+ INPUT : 3 -> __table2.id UInt64 : 3
ALIAS __table1.id :: 0 -> id UInt64 : 4
ALIAS __table1.value :: 1 -> value String : 0
- ALIAS __table2.id :: 2 -> rhs.id UInt64 : 1
- ALIAS __table2.value :: 3 -> rhs.value String : 2
-Positions: 4 1 0 2
+ ALIAS __table2.value :: 2 -> rhs.value String : 1
+ ALIAS __table2.id :: 3 -> rhs.id UInt64 : 2
+Positions: 4 2 0 1
Join (JOIN FillRightFirst)
Header: __table1.id UInt64
__table1.value String
- __table2.id UInt64
__table2.value String
+ __table2.id UInt64
Type: INNER
Strictness: ALL
Algorithm: HashJoin
@@ -71,9 +69,7 @@ SELECT '--';
--
EXPLAIN header = 1, actions = 1
SELECT lhs.id, rhs.id, lhs.value, rhs.value FROM test_table_1 AS lhs INNER JOIN test_table_2 AS rhs ON lhs.id = rhs.id
-WHERE rhs.id = 5
-SETTINGS query_plan_join_inner_table_selection = 'right';
-;
+WHERE rhs.id = 5;
Expression ((Project names + (Projection + )))
Header: id UInt64
rhs.id UInt64
@@ -81,18 +77,18 @@ Header: id UInt64
rhs.value String
Actions: INPUT : 0 -> __table1.id UInt64 : 0
INPUT : 1 -> __table1.value String : 1
- INPUT : 2 -> __table2.id UInt64 : 2
- INPUT : 3 -> __table2.value String : 3
+ INPUT : 2 -> __table2.value String : 2
+ INPUT : 3 -> __table2.id UInt64 : 3
ALIAS __table1.id :: 0 -> id UInt64 : 4
ALIAS __table1.value :: 1 -> value String : 0
- ALIAS __table2.id :: 2 -> rhs.id UInt64 : 1
- ALIAS __table2.value :: 3 -> rhs.value String : 2
-Positions: 4 1 0 2
+ ALIAS __table2.value :: 2 -> rhs.value String : 1
+ ALIAS __table2.id :: 3 -> rhs.id UInt64 : 2
+Positions: 4 2 0 1
Join (JOIN FillRightFirst)
Header: __table1.id UInt64
__table1.value String
- __table2.id UInt64
__table2.value String
+ __table2.id UInt64
Type: INNER
Strictness: ALL
Algorithm: HashJoin
@@ -140,9 +136,7 @@ SELECT '--';
--
EXPLAIN header = 1, actions = 1
SELECT lhs.id, rhs.id, lhs.value, rhs.value FROM test_table_1 AS lhs INNER JOIN test_table_2 AS rhs ON lhs.id = rhs.id
-WHERE lhs.id = 5 AND rhs.id = 6
-SETTINGS query_plan_join_inner_table_selection = 'right'
-;
+WHERE lhs.id = 5 AND rhs.id = 6;
Expression ((Project names + (Projection + )))
Header: id UInt64
rhs.id UInt64
@@ -150,18 +144,18 @@ Header: id UInt64
rhs.value String
Actions: INPUT : 0 -> __table1.id UInt64 : 0
INPUT : 1 -> __table1.value String : 1
- INPUT : 2 -> __table2.id UInt64 : 2
- INPUT : 3 -> __table2.value String : 3
+ INPUT : 2 -> __table2.value String : 2
+ INPUT : 3 -> __table2.id UInt64 : 3
ALIAS __table1.id :: 0 -> id UInt64 : 4
ALIAS __table1.value :: 1 -> value String : 0
- ALIAS __table2.id :: 2 -> rhs.id UInt64 : 1
- ALIAS __table2.value :: 3 -> rhs.value String : 2
-Positions: 4 1 0 2
+ ALIAS __table2.value :: 2 -> rhs.value String : 1
+ ALIAS __table2.id :: 3 -> rhs.id UInt64 : 2
+Positions: 4 2 0 1
Join (JOIN FillRightFirst)
Header: __table1.id UInt64
__table1.value String
- __table2.id UInt64
__table2.value String
+ __table2.id UInt64
Type: INNER
Strictness: ALL
Algorithm: HashJoin
@@ -212,9 +206,7 @@ SELECT '--';
--
EXPLAIN header = 1, actions = 1
SELECT lhs.id, rhs.id, lhs.value, rhs.value FROM test_table_1 AS lhs LEFT JOIN test_table_2 AS rhs ON lhs.id = rhs.id
-WHERE lhs.id = 5
-SETTINGS query_plan_join_inner_table_selection = 'right'
-;
+WHERE lhs.id = 5;
Expression ((Project names + (Projection + )))
Header: id UInt64
rhs.id UInt64
@@ -222,18 +214,18 @@ Header: id UInt64
rhs.value String
Actions: INPUT : 0 -> __table1.id UInt64 : 0
INPUT : 1 -> __table1.value String : 1
- INPUT : 2 -> __table2.id UInt64 : 2
- INPUT : 3 -> __table2.value String : 3
+ INPUT : 2 -> __table2.value String : 2
+ INPUT : 3 -> __table2.id UInt64 : 3
ALIAS __table1.id :: 0 -> id UInt64 : 4
ALIAS __table1.value :: 1 -> value String : 0
- ALIAS __table2.id :: 2 -> rhs.id UInt64 : 1
- ALIAS __table2.value :: 3 -> rhs.value String : 2
-Positions: 4 1 0 2
+ ALIAS __table2.value :: 2 -> rhs.value String : 1
+ ALIAS __table2.id :: 3 -> rhs.id UInt64 : 2
+Positions: 4 2 0 1
Join (JOIN FillRightFirst)
Header: __table1.id UInt64
__table1.value String
- __table2.id UInt64
__table2.value String
+ __table2.id UInt64
Type: LEFT
Strictness: ALL
Algorithm: HashJoin
@@ -281,9 +273,7 @@ SELECT '--';
--
EXPLAIN header = 1, actions = 1
SELECT lhs.id, rhs.id, lhs.value, rhs.value FROM test_table_1 AS lhs LEFT JOIN test_table_2 AS rhs ON lhs.id = rhs.id
-WHERE rhs.id = 5
-SETTINGS query_plan_join_inner_table_selection = 'right'
-;
+WHERE rhs.id = 5;
Expression ((Project names + Projection))
Header: id UInt64
rhs.id UInt64
@@ -291,31 +281,31 @@ Header: id UInt64
rhs.value String
Actions: INPUT : 0 -> __table1.id UInt64 : 0
INPUT : 1 -> __table1.value String : 1
- INPUT : 2 -> __table2.id UInt64 : 2
- INPUT : 3 -> __table2.value String : 3
+ INPUT : 2 -> __table2.value String : 2
+ INPUT : 3 -> __table2.id UInt64 : 3
ALIAS __table1.id :: 0 -> id UInt64 : 4
ALIAS __table1.value :: 1 -> value String : 0
- ALIAS __table2.id :: 2 -> rhs.id UInt64 : 1
- ALIAS __table2.value :: 3 -> rhs.value String : 2
-Positions: 4 1 0 2
- Filter (WHERE)
+ ALIAS __table2.value :: 2 -> rhs.value String : 1
+ ALIAS __table2.id :: 3 -> rhs.id UInt64 : 2
+Positions: 4 2 0 1
+ Filter ((WHERE + DROP unused columns after JOIN))
Header: __table1.id UInt64
__table1.value String
- __table2.id UInt64
__table2.value String
+ __table2.id UInt64
Filter column: equals(__table2.id, 5_UInt8) (removed)
Actions: INPUT :: 0 -> __table1.id UInt64 : 0
INPUT :: 1 -> __table1.value String : 1
- INPUT : 2 -> __table2.id UInt64 : 2
- INPUT :: 3 -> __table2.value String : 3
+ INPUT :: 2 -> __table2.value String : 2
+ INPUT : 3 -> __table2.id UInt64 : 3
COLUMN Const(UInt8) -> 5_UInt8 UInt8 : 4
- FUNCTION equals(__table2.id : 2, 5_UInt8 :: 4) -> equals(__table2.id, 5_UInt8) UInt8 : 5
+ FUNCTION equals(__table2.id : 3, 5_UInt8 :: 4) -> equals(__table2.id, 5_UInt8) UInt8 : 5
Positions: 5 0 1 2 3
Join (JOIN FillRightFirst)
Header: __table1.id UInt64
__table1.value String
- __table2.id UInt64
__table2.value String
+ __table2.id UInt64
Type: LEFT
Strictness: ALL
Algorithm: HashJoin
@@ -357,9 +347,7 @@ SELECT '--';
--
EXPLAIN header = 1, actions = 1
SELECT lhs.id, rhs.id, lhs.value, rhs.value FROM test_table_1 AS lhs RIGHT JOIN test_table_2 AS rhs ON lhs.id = rhs.id
-WHERE lhs.id = 5
-SETTINGS query_plan_join_inner_table_selection = 'right'
-;
+WHERE lhs.id = 5;
Expression ((Project names + Projection))
Header: id UInt64
rhs.id UInt64
@@ -367,31 +355,31 @@ Header: id UInt64
rhs.value String
Actions: INPUT : 0 -> __table1.id UInt64 : 0
INPUT : 1 -> __table1.value String : 1
- INPUT : 2 -> __table2.id UInt64 : 2
- INPUT : 3 -> __table2.value String : 3
+ INPUT : 2 -> __table2.value String : 2
+ INPUT : 3 -> __table2.id UInt64 : 3
ALIAS __table1.id :: 0 -> id UInt64 : 4
ALIAS __table1.value :: 1 -> value String : 0
- ALIAS __table2.id :: 2 -> rhs.id UInt64 : 1
- ALIAS __table2.value :: 3 -> rhs.value String : 2
-Positions: 4 1 0 2
- Filter (WHERE)
+ ALIAS __table2.value :: 2 -> rhs.value String : 1
+ ALIAS __table2.id :: 3 -> rhs.id UInt64 : 2
+Positions: 4 2 0 1
+ Filter ((WHERE + DROP unused columns after JOIN))
Header: __table1.id UInt64
__table1.value String
- __table2.id UInt64
__table2.value String
+ __table2.id UInt64
Filter column: equals(__table1.id, 5_UInt8) (removed)
Actions: INPUT : 0 -> __table1.id UInt64 : 0
INPUT :: 1 -> __table1.value String : 1
- INPUT :: 2 -> __table2.id UInt64 : 2
- INPUT :: 3 -> __table2.value String : 3
+ INPUT :: 2 -> __table2.value String : 2
+ INPUT :: 3 -> __table2.id UInt64 : 3
COLUMN Const(UInt8) -> 5_UInt8 UInt8 : 4
FUNCTION equals(__table1.id : 0, 5_UInt8 :: 4) -> equals(__table1.id, 5_UInt8) UInt8 : 5
Positions: 5 0 1 2 3
Join (JOIN FillRightFirst)
Header: __table1.id UInt64
__table1.value String
- __table2.id UInt64
__table2.value String
+ __table2.id UInt64
Type: RIGHT
Strictness: ALL
Algorithm: HashJoin
@@ -433,9 +421,7 @@ SELECT '--';
--
EXPLAIN header = 1, actions = 1
SELECT lhs.id, rhs.id, lhs.value, rhs.value FROM test_table_1 AS lhs RIGHT JOIN test_table_2 AS rhs ON lhs.id = rhs.id
-WHERE rhs.id = 5
-SETTINGS query_plan_join_inner_table_selection = 'right'
-;
+WHERE rhs.id = 5;
Expression ((Project names + (Projection + )))
Header: id UInt64
rhs.id UInt64
@@ -443,18 +429,18 @@ Header: id UInt64
rhs.value String
Actions: INPUT : 0 -> __table1.id UInt64 : 0
INPUT : 1 -> __table1.value String : 1
- INPUT : 2 -> __table2.id UInt64 : 2
- INPUT : 3 -> __table2.value String : 3
+ INPUT : 2 -> __table2.value String : 2
+ INPUT : 3 -> __table2.id UInt64 : 3
ALIAS __table1.id :: 0 -> id UInt64 : 4
ALIAS __table1.value :: 1 -> value String : 0
- ALIAS __table2.id :: 2 -> rhs.id UInt64 : 1
- ALIAS __table2.value :: 3 -> rhs.value String : 2
-Positions: 4 1 0 2
+ ALIAS __table2.value :: 2 -> rhs.value String : 1
+ ALIAS __table2.id :: 3 -> rhs.id UInt64 : 2
+Positions: 4 2 0 1
Join (JOIN FillRightFirst)
Header: __table1.id UInt64
__table1.value String
- __table2.id UInt64
__table2.value String
+ __table2.id UInt64
Type: RIGHT
Strictness: ALL
Algorithm: HashJoin
@@ -502,9 +488,7 @@ SELECT '--';
--
EXPLAIN header = 1, actions = 1
SELECT lhs.id, rhs.id, lhs.value, rhs.value FROM test_table_1 AS lhs FULL JOIN test_table_2 AS rhs ON lhs.id = rhs.id
-WHERE lhs.id = 5
-SETTINGS query_plan_join_inner_table_selection = 'right'
-;
+WHERE lhs.id = 5;
Expression ((Project names + Projection))
Header: id UInt64
rhs.id UInt64
@@ -512,31 +496,31 @@ Header: id UInt64
rhs.value String
Actions: INPUT : 0 -> __table1.id UInt64 : 0
INPUT : 1 -> __table1.value String : 1
- INPUT : 2 -> __table2.id UInt64 : 2
- INPUT : 3 -> __table2.value String : 3
+ INPUT : 2 -> __table2.value String : 2
+ INPUT : 3 -> __table2.id UInt64 : 3
ALIAS __table1.id :: 0 -> id UInt64 : 4
ALIAS __table1.value :: 1 -> value String : 0
- ALIAS __table2.id :: 2 -> rhs.id UInt64 : 1
- ALIAS __table2.value :: 3 -> rhs.value String : 2
-Positions: 4 1 0 2
- Filter (WHERE)
+ ALIAS __table2.value :: 2 -> rhs.value String : 1
+ ALIAS __table2.id :: 3 -> rhs.id UInt64 : 2
+Positions: 4 2 0 1
+ Filter ((WHERE + DROP unused columns after JOIN))
Header: __table1.id UInt64
__table1.value String
- __table2.id UInt64
__table2.value String
+ __table2.id UInt64
Filter column: equals(__table1.id, 5_UInt8) (removed)
Actions: INPUT : 0 -> __table1.id UInt64 : 0
INPUT :: 1 -> __table1.value String : 1
- INPUT :: 2 -> __table2.id UInt64 : 2
- INPUT :: 3 -> __table2.value String : 3
+ INPUT :: 2 -> __table2.value String : 2
+ INPUT :: 3 -> __table2.id UInt64 : 3
COLUMN Const(UInt8) -> 5_UInt8 UInt8 : 4
FUNCTION equals(__table1.id : 0, 5_UInt8 :: 4) -> equals(__table1.id, 5_UInt8) UInt8 : 5
Positions: 5 0 1 2 3
Join (JOIN FillRightFirst)
Header: __table1.id UInt64
__table1.value String
- __table2.id UInt64
__table2.value String
+ __table2.id UInt64
Type: FULL
Strictness: ALL
Algorithm: HashJoin
@@ -578,9 +562,7 @@ SELECT '--';
--
EXPLAIN header = 1, actions = 1
SELECT lhs.id, rhs.id, lhs.value, rhs.value FROM test_table_1 AS lhs FULL JOIN test_table_2 AS rhs ON lhs.id = rhs.id
-WHERE rhs.id = 5
-SETTINGS query_plan_join_inner_table_selection = 'right'
-;
+WHERE rhs.id = 5;
Expression ((Project names + Projection))
Header: id UInt64
rhs.id UInt64
@@ -588,31 +570,31 @@ Header: id UInt64
rhs.value String
Actions: INPUT : 0 -> __table1.id UInt64 : 0
INPUT : 1 -> __table1.value String : 1
- INPUT : 2 -> __table2.id UInt64 : 2
- INPUT : 3 -> __table2.value String : 3
+ INPUT : 2 -> __table2.value String : 2
+ INPUT : 3 -> __table2.id UInt64 : 3
ALIAS __table1.id :: 0 -> id UInt64 : 4
ALIAS __table1.value :: 1 -> value String : 0
- ALIAS __table2.id :: 2 -> rhs.id UInt64 : 1
- ALIAS __table2.value :: 3 -> rhs.value String : 2
-Positions: 4 1 0 2
- Filter (WHERE)
+ ALIAS __table2.value :: 2 -> rhs.value String : 1
+ ALIAS __table2.id :: 3 -> rhs.id UInt64 : 2
+Positions: 4 2 0 1
+ Filter ((WHERE + DROP unused columns after JOIN))
Header: __table1.id UInt64
__table1.value String
- __table2.id UInt64
__table2.value String
+ __table2.id UInt64
Filter column: equals(__table2.id, 5_UInt8) (removed)
Actions: INPUT :: 0 -> __table1.id UInt64 : 0
INPUT :: 1 -> __table1.value String : 1
- INPUT : 2 -> __table2.id UInt64 : 2
- INPUT :: 3 -> __table2.value String : 3
+ INPUT :: 2 -> __table2.value String : 2
+ INPUT : 3 -> __table2.id UInt64 : 3
COLUMN Const(UInt8) -> 5_UInt8 UInt8 : 4
- FUNCTION equals(__table2.id : 2, 5_UInt8 :: 4) -> equals(__table2.id, 5_UInt8) UInt8 : 5
+ FUNCTION equals(__table2.id : 3, 5_UInt8 :: 4) -> equals(__table2.id, 5_UInt8) UInt8 : 5
Positions: 5 0 1 2 3
Join (JOIN FillRightFirst)
Header: __table1.id UInt64
__table1.value String
- __table2.id UInt64
__table2.value String
+ __table2.id UInt64
Type: FULL
Strictness: ALL
Algorithm: HashJoin
@@ -654,9 +636,7 @@ SELECT '--';
--
EXPLAIN header = 1, actions = 1
SELECT lhs.id, rhs.id, lhs.value, rhs.value FROM test_table_1 AS lhs FULL JOIN test_table_2 AS rhs ON lhs.id = rhs.id
-WHERE lhs.id = 5 AND rhs.id = 6
-SETTINGS query_plan_join_inner_table_selection = 'right'
-;
+WHERE lhs.id = 5 AND rhs.id = 6;
Expression ((Project names + Projection))
Header: id UInt64
rhs.id UInt64
@@ -664,34 +644,34 @@ Header: id UInt64
rhs.value String
Actions: INPUT : 0 -> __table1.id UInt64 : 0
INPUT : 1 -> __table1.value String : 1
- INPUT : 2 -> __table2.id UInt64 : 2
- INPUT : 3 -> __table2.value String : 3
+ INPUT : 2 -> __table2.value String : 2
+ INPUT : 3 -> __table2.id UInt64 : 3
ALIAS __table1.id :: 0 -> id UInt64 : 4
ALIAS __table1.value :: 1 -> value String : 0
- ALIAS __table2.id :: 2 -> rhs.id UInt64 : 1
- ALIAS __table2.value :: 3 -> rhs.value String : 2
-Positions: 4 1 0 2
- Filter (WHERE)
+ ALIAS __table2.value :: 2 -> rhs.value String : 1
+ ALIAS __table2.id :: 3 -> rhs.id UInt64 : 2
+Positions: 4 2 0 1
+ Filter ((WHERE + DROP unused columns after JOIN))
Header: __table1.id UInt64
__table1.value String
- __table2.id UInt64
__table2.value String
+ __table2.id UInt64
Filter column: and(equals(__table1.id, 5_UInt8), equals(__table2.id, 6_UInt8)) (removed)
Actions: INPUT : 0 -> __table1.id UInt64 : 0
INPUT :: 1 -> __table1.value String : 1
- INPUT : 2 -> __table2.id UInt64 : 2
- INPUT :: 3 -> __table2.value String : 3
+ INPUT :: 2 -> __table2.value String : 2
+ INPUT : 3 -> __table2.id UInt64 : 3
COLUMN Const(UInt8) -> 5_UInt8 UInt8 : 4
COLUMN Const(UInt8) -> 6_UInt8 UInt8 : 5
FUNCTION equals(__table1.id : 0, 5_UInt8 :: 4) -> equals(__table1.id, 5_UInt8) UInt8 : 6
- FUNCTION equals(__table2.id : 2, 6_UInt8 :: 5) -> equals(__table2.id, 6_UInt8) UInt8 : 4
+ FUNCTION equals(__table2.id : 3, 6_UInt8 :: 5) -> equals(__table2.id, 6_UInt8) UInt8 : 4
FUNCTION and(equals(__table1.id, 5_UInt8) :: 6, equals(__table2.id, 6_UInt8) :: 4) -> and(equals(__table1.id, 5_UInt8), equals(__table2.id, 6_UInt8)) UInt8 : 5
Positions: 5 0 1 2 3
Join (JOIN FillRightFirst)
Header: __table1.id UInt64
__table1.value String
- __table2.id UInt64
__table2.value String
+ __table2.id UInt64
Type: FULL
Strictness: ALL
Algorithm: HashJoin
diff --git a/tests/queries/0_stateless/03036_join_filter_push_down_equivalent_sets.sql b/tests/queries/0_stateless/03036_join_filter_push_down_equivalent_sets.sql
index d6dcc34c796..e1a13d1ce71 100644
--- a/tests/queries/0_stateless/03036_join_filter_push_down_equivalent_sets.sql
+++ b/tests/queries/0_stateless/03036_join_filter_push_down_equivalent_sets.sql
@@ -22,9 +22,7 @@ INSERT INTO test_table_2 SELECT number, number FROM numbers(10);
EXPLAIN header = 1, actions = 1
SELECT lhs.id, rhs.id, lhs.value, rhs.value FROM test_table_1 AS lhs INNER JOIN test_table_2 AS rhs ON lhs.id = rhs.id
-WHERE lhs.id = 5
-SETTINGS query_plan_join_inner_table_selection = 'right'
-;
+WHERE lhs.id = 5;
SELECT '--';
@@ -35,9 +33,7 @@ SELECT '--';
EXPLAIN header = 1, actions = 1
SELECT lhs.id, rhs.id, lhs.value, rhs.value FROM test_table_1 AS lhs INNER JOIN test_table_2 AS rhs ON lhs.id = rhs.id
-WHERE rhs.id = 5
-SETTINGS query_plan_join_inner_table_selection = 'right';
-;
+WHERE rhs.id = 5;
SELECT '--';
@@ -48,9 +44,7 @@ SELECT '--';
EXPLAIN header = 1, actions = 1
SELECT lhs.id, rhs.id, lhs.value, rhs.value FROM test_table_1 AS lhs INNER JOIN test_table_2 AS rhs ON lhs.id = rhs.id
-WHERE lhs.id = 5 AND rhs.id = 6
-SETTINGS query_plan_join_inner_table_selection = 'right'
-;
+WHERE lhs.id = 5 AND rhs.id = 6;
SELECT lhs.id, rhs.id, lhs.value, rhs.value FROM test_table_1 AS lhs INNER JOIN test_table_2 AS rhs ON lhs.id = rhs.id
WHERE lhs.id = 5 AND rhs.id = 6;
@@ -59,9 +53,7 @@ SELECT '--';
EXPLAIN header = 1, actions = 1
SELECT lhs.id, rhs.id, lhs.value, rhs.value FROM test_table_1 AS lhs LEFT JOIN test_table_2 AS rhs ON lhs.id = rhs.id
-WHERE lhs.id = 5
-SETTINGS query_plan_join_inner_table_selection = 'right'
-;
+WHERE lhs.id = 5;
SELECT '--';
@@ -72,9 +64,7 @@ SELECT '--';
EXPLAIN header = 1, actions = 1
SELECT lhs.id, rhs.id, lhs.value, rhs.value FROM test_table_1 AS lhs LEFT JOIN test_table_2 AS rhs ON lhs.id = rhs.id
-WHERE rhs.id = 5
-SETTINGS query_plan_join_inner_table_selection = 'right'
-;
+WHERE rhs.id = 5;
SELECT '--';
@@ -85,9 +75,7 @@ SELECT '--';
EXPLAIN header = 1, actions = 1
SELECT lhs.id, rhs.id, lhs.value, rhs.value FROM test_table_1 AS lhs RIGHT JOIN test_table_2 AS rhs ON lhs.id = rhs.id
-WHERE lhs.id = 5
-SETTINGS query_plan_join_inner_table_selection = 'right'
-;
+WHERE lhs.id = 5;
SELECT '--';
@@ -98,9 +86,7 @@ SELECT '--';
EXPLAIN header = 1, actions = 1
SELECT lhs.id, rhs.id, lhs.value, rhs.value FROM test_table_1 AS lhs RIGHT JOIN test_table_2 AS rhs ON lhs.id = rhs.id
-WHERE rhs.id = 5
-SETTINGS query_plan_join_inner_table_selection = 'right'
-;
+WHERE rhs.id = 5;
SELECT '--';
@@ -111,9 +97,7 @@ SELECT '--';
EXPLAIN header = 1, actions = 1
SELECT lhs.id, rhs.id, lhs.value, rhs.value FROM test_table_1 AS lhs FULL JOIN test_table_2 AS rhs ON lhs.id = rhs.id
-WHERE lhs.id = 5
-SETTINGS query_plan_join_inner_table_selection = 'right'
-;
+WHERE lhs.id = 5;
SELECT '--';
@@ -124,9 +108,7 @@ SELECT '--';
EXPLAIN header = 1, actions = 1
SELECT lhs.id, rhs.id, lhs.value, rhs.value FROM test_table_1 AS lhs FULL JOIN test_table_2 AS rhs ON lhs.id = rhs.id
-WHERE rhs.id = 5
-SETTINGS query_plan_join_inner_table_selection = 'right'
-;
+WHERE rhs.id = 5;
SELECT '--';
@@ -137,9 +119,7 @@ SELECT '--';
EXPLAIN header = 1, actions = 1
SELECT lhs.id, rhs.id, lhs.value, rhs.value FROM test_table_1 AS lhs FULL JOIN test_table_2 AS rhs ON lhs.id = rhs.id
-WHERE lhs.id = 5 AND rhs.id = 6
-SETTINGS query_plan_join_inner_table_selection = 'right'
-;
+WHERE lhs.id = 5 AND rhs.id = 6;
SELECT '--';
diff --git a/tests/queries/0_stateless/03038_recursive_cte_postgres_4.reference b/tests/queries/0_stateless/03038_recursive_cte_postgres_4.reference
index 7df38e855f6..cf070eebc38 100644
--- a/tests/queries/0_stateless/03038_recursive_cte_postgres_4.reference
+++ b/tests/queries/0_stateless/03038_recursive_cte_postgres_4.reference
@@ -52,9 +52,7 @@ WITH RECURSIVE search_graph AS (
FROM graph g, search_graph sg
WHERE g.f = sg.t AND NOT is_cycle
)
-SELECT * FROM search_graph
-SETTINGS query_plan_join_inner_table_selection = 'right'
-;
+SELECT * FROM search_graph;
1 2 arc 1 -> 2 false [(1,2)]
1 3 arc 1 -> 3 false [(1,3)]
2 3 arc 2 -> 3 false [(2,3)]
diff --git a/tests/queries/0_stateless/03038_recursive_cte_postgres_4.sql b/tests/queries/0_stateless/03038_recursive_cte_postgres_4.sql
index d33ca7b078e..7dad74893b9 100644
--- a/tests/queries/0_stateless/03038_recursive_cte_postgres_4.sql
+++ b/tests/queries/0_stateless/03038_recursive_cte_postgres_4.sql
@@ -55,9 +55,7 @@ WITH RECURSIVE search_graph AS (
FROM graph g, search_graph sg
WHERE g.f = sg.t AND NOT is_cycle
)
-SELECT * FROM search_graph
-SETTINGS query_plan_join_inner_table_selection = 'right'
-;
+SELECT * FROM search_graph;
-- ordering by the path column has same effect as SEARCH DEPTH FIRST
WITH RECURSIVE search_graph AS (
diff --git a/tests/queries/0_stateless/03094_one_thousand_joins.sql b/tests/queries/0_stateless/03094_one_thousand_joins.sql
index 69c4fb42a6b..6ae4e4d4d3c 100644
--- a/tests/queries/0_stateless/03094_one_thousand_joins.sql
+++ b/tests/queries/0_stateless/03094_one_thousand_joins.sql
@@ -3,7 +3,6 @@
SET join_algorithm = 'default'; -- for 'full_sorting_merge' the query is 10x slower
SET enable_analyzer = 1; -- old analyzer returns TOO_DEEP_SUBQUERIES
-SET query_plan_join_inner_table_selection = 'auto'; -- 'left' is slower
-- Bug 33446, marked as 'long' because it still runs around 10 sec
SELECT * FROM (SELECT 1 AS x) t1 JOIN (SELECT 1 AS x) t2 ON t1.x = t2.x JOIN (SELECT 1 AS x) t3 ON t1.x = t3.x JOIN (SELECT 1 AS x) t4 ON t1.x = t4.x JOIN (SELECT 1 AS x) t5 ON t1.x = t5.x JOIN (SELECT 1 AS x) t6 ON t1.x = t6.x JOIN (SELECT 1 AS x) t7 ON t1.x = t7.x JOIN (SELECT 1 AS x) t8 ON t1.x = t8.x JOIN (SELECT 1 AS x) t9 ON t1.x = t9.x JOIN (SELECT 1 AS x) t10 ON t1.x = t10.x JOIN (SELECT 1 AS x) t11 ON t1.x = t11.x JOIN (SELECT 1 AS x) t12 ON t1.x = t12.x JOIN (SELECT 1 AS x) t13 ON t1.x = t13.x JOIN (SELECT 1 AS x) t14 ON t1.x = t14.x JOIN (SELECT 1 AS x) t15 ON t1.x = t15.x JOIN (SELECT 1 AS x) t16 ON t1.x = t16.x JOIN (SELECT 1 AS x) t17 ON t1.x = t17.x JOIN (SELECT 1 AS x) t18 ON t1.x = t18.x JOIN (SELECT 1 AS x) t19 ON t1.x = t19.x JOIN (SELECT 1 AS x) t20 ON t1.x = t20.x JOIN (SELECT 1 AS x) t21 ON t1.x = t21.x JOIN (SELECT 1 AS x) t22 ON t1.x = t22.x JOIN (SELECT 1 AS x) t23 ON t1.x = t23.x JOIN (SELECT 1 AS x) t24 ON t1.x = t24.x JOIN (SELECT 1 AS x) t25 ON t1.x = t25.x JOIN (SELECT 1 AS x) t26 ON t1.x = t26.x JOIN (SELECT 1 AS x) t27 ON t1.x = t27.x JOIN (SELECT 1 AS x) t28 ON t1.x = t28.x JOIN (SELECT 1 AS x) t29 ON t1.x = t29.x JOIN (SELECT 1 AS x) t30 ON t1.x = t30.x JOIN (SELECT 1 AS x) t31 ON t1.x = t31.x JOIN (SELECT 1 AS x) t32 ON t1.x = t32.x JOIN (SELECT 1 AS x) t33 ON t1.x = t33.x JOIN (SELECT 1 AS x) t34 ON t1.x = t34.x JOIN (SELECT 1 AS x) t35 ON t1.x = t35.x JOIN (SELECT 1 AS x) t36 ON t1.x = t36.x JOIN (SELECT 1 AS x) t37 ON t1.x = t37.x JOIN (SELECT 1 AS x) t38 ON t1.x = t38.x JOIN (SELECT 1 AS x) t39 ON t1.x = t39.x JOIN (SELECT 1 AS x) t40 ON t1.x = t40.x JOIN (SELECT 1 AS x) t41 ON t1.x = t41.x JOIN (SELECT 1 AS x) t42 ON t1.x = t42.x JOIN (SELECT 1 AS x) t43 ON t1.x = t43.x JOIN (SELECT 1 AS x) t44 ON t1.x = t44.x JOIN (SELECT 1 AS x) t45 ON t1.x = t45.x JOIN (SELECT 1 AS x) t46 ON t1.x = t46.x JOIN (SELECT 1 AS x) t47 ON t1.x = t47.x JOIN (SELECT 1 AS x) t48 ON t1.x = t48.x JOIN (SELECT 1 AS x) t49 ON t1.x = t49.x JOIN (SELECT 1 AS x) t50 ON t1.x = t50.x JOIN (SELECT 1 AS x) t51 ON t1.x = t51.x JOIN (SELECT 1 AS x) t52 ON t1.x = t52.x JOIN (SELECT 1 AS x) t53 ON t1.x = t53.x JOIN (SELECT 1 AS x) t54 ON t1.x = t54.x JOIN (SELECT 1 AS x) t55 ON t1.x = t55.x JOIN (SELECT 1 AS x) t56 ON t1.x = t56.x JOIN (SELECT 1 AS x) t57 ON t1.x = t57.x JOIN (SELECT 1 AS x) t58 ON t1.x = t58.x JOIN (SELECT 1 AS x) t59 ON t1.x = t59.x JOIN (SELECT 1 AS x) t60 ON t1.x = t60.x JOIN (SELECT 1 AS x) t61 ON t1.x = t61.x JOIN (SELECT 1 AS x) t62 ON t1.x = t62.x JOIN (SELECT 1 AS x) t63 ON t1.x = t63.x JOIN (SELECT 1 AS x) t64 ON t1.x = t64.x JOIN (SELECT 1 AS x) t65 ON t1.x = t65.x JOIN (SELECT 1 AS x) t66 ON t1.x = t66.x JOIN (SELECT 1 AS x) t67 ON t1.x = t67.x JOIN (SELECT 1 AS x) t68 ON t1.x = t68.x JOIN (SELECT 1 AS x) t69 ON t1.x = t69.x JOIN (SELECT 1 AS x) t70 ON t1.x = t70.x JOIN (SELECT 1 AS x) t71 ON t1.x = t71.x JOIN (SELECT 1 AS x) t72 ON t1.x = t72.x JOIN (SELECT 1 AS x) t73 ON t1.x = t73.x JOIN (SELECT 1 AS x) t74 ON t1.x = t74.x JOIN (SELECT 1 AS x) t75 ON t1.x = t75.x JOIN (SELECT 1 AS x) t76 ON t1.x = t76.x JOIN (SELECT 1 AS x) t77 ON t1.x = t77.x JOIN (SELECT 1 AS x) t78 ON t1.x = t78.x JOIN (SELECT 1 AS x) t79 ON t1.x = t79.x JOIN (SELECT 1 AS x) t80 ON t1.x = t80.x JOIN (SELECT 1 AS x) t81 ON t1.x = t81.x JOIN (SELECT 1 AS x) t82 ON t1.x = t82.x JOIN (SELECT 1 AS x) t83 ON t1.x = t83.x JOIN (SELECT 1 AS x) t84 ON t1.x = t84.x JOIN (SELECT 1 AS x) t85 ON t1.x = t85.x JOIN (SELECT 1 AS x) t86 ON t1.x = t86.x JOIN (SELECT 1 AS x) t87 ON t1.x = t87.x JOIN (SELECT 1 AS x) t88 ON t1.x = t88.x JOIN (SELECT 1 AS x) t89 ON t1.x = t89.x JOIN (SELECT 1 AS x) t90 ON t1.x = t90.x JOIN (SELECT 1 AS x) t91 ON t1.x = t91.x JOIN (SELECT 1 AS x) t92 ON t1.x = t92.x JOIN (SELECT 1 AS x) t93 ON t1.x = t93.x JOIN (SELECT 1 AS x) t94 ON t1.x = t94.x JOIN (SELECT 1 AS x) t95 ON t1.x = t95.x JOIN (SELECT 1 AS x) t96 ON t1.x = t96.x JOIN (SELECT 1 AS x) t97 ON t1.x = t97.x JOIN (SELECT 1 AS x) t98 ON t1.x = t98.x JOIN (SELECT 1 AS x) t99 ON t1.x = t99.x JOIN (SELECT 1 AS x) t100 ON t1.x = t100.x JOIN (SELECT 1 AS x) t101 ON t1.x = t101.x JOIN (SELECT 1 AS x) t102 ON t1.x = t102.x JOIN (SELECT 1 AS x) t103 ON t1.x = t103.x JOIN (SELECT 1 AS x) t104 ON t1.x = t104.x JOIN (SELECT 1 AS x) t105 ON t1.x = t105.x JOIN (SELECT 1 AS x) t106 ON t1.x = t106.x JOIN (SELECT 1 AS x) t107 ON t1.x = t107.x JOIN (SELECT 1 AS x) t108 ON t1.x = t108.x JOIN (SELECT 1 AS x) t109 ON t1.x = t109.x JOIN (SELECT 1 AS x) t110 ON t1.x = t110.x JOIN (SELECT 1 AS x) t111 ON t1.x = t111.x JOIN (SELECT 1 AS x) t112 ON t1.x = t112.x JOIN (SELECT 1 AS x) t113 ON t1.x = t113.x JOIN (SELECT 1 AS x) t114 ON t1.x = t114.x JOIN (SELECT 1 AS x) t115 ON t1.x = t115.x JOIN (SELECT 1 AS x) t116 ON t1.x = t116.x JOIN (SELECT 1 AS x) t117 ON t1.x = t117.x JOIN (SELECT 1 AS x) t118 ON t1.x = t118.x JOIN (SELECT 1 AS x) t119 ON t1.x = t119.x JOIN (SELECT 1 AS x) t120 ON t1.x = t120.x JOIN (SELECT 1 AS x) t121 ON t1.x = t121.x JOIN (SELECT 1 AS x) t122 ON t1.x = t122.x JOIN (SELECT 1 AS x) t123 ON t1.x = t123.x JOIN (SELECT 1 AS x) t124 ON t1.x = t124.x JOIN (SELECT 1 AS x) t125 ON t1.x = t125.x JOIN (SELECT 1 AS x) t126 ON t1.x = t126.x JOIN (SELECT 1 AS x) t127 ON t1.x = t127.x JOIN (SELECT 1 AS x) t128 ON t1.x = t128.x JOIN (SELECT 1 AS x) t129 ON t1.x = t129.x JOIN (SELECT 1 AS x) t130 ON t1.x = t130.x JOIN (SELECT 1 AS x) t131 ON t1.x = t131.x JOIN (SELECT 1 AS x) t132 ON t1.x = t132.x JOIN (SELECT 1 AS x) t133 ON t1.x = t133.x JOIN (SELECT 1 AS x) t134 ON t1.x = t134.x JOIN (SELECT 1 AS x) t135 ON t1.x = t135.x JOIN (SELECT 1 AS x) t136 ON t1.x = t136.x JOIN (SELECT 1 AS x) t137 ON t1.x = t137.x JOIN (SELECT 1 AS x) t138 ON t1.x = t138.x JOIN (SELECT 1 AS x) t139 ON t1.x = t139.x JOIN (SELECT 1 AS x) t140 ON t1.x = t140.x JOIN (SELECT 1 AS x) t141 ON t1.x = t141.x JOIN (SELECT 1 AS x) t142 ON t1.x = t142.x JOIN (SELECT 1 AS x) t143 ON t1.x = t143.x JOIN (SELECT 1 AS x) t144 ON t1.x = t144.x JOIN (SELECT 1 AS x) t145 ON t1.x = t145.x JOIN (SELECT 1 AS x) t146 ON t1.x = t146.x JOIN (SELECT 1 AS x) t147 ON t1.x = t147.x JOIN (SELECT 1 AS x) t148 ON t1.x = t148.x JOIN (SELECT 1 AS x) t149 ON t1.x = t149.x JOIN (SELECT 1 AS x) t150 ON t1.x = t150.x JOIN (SELECT 1 AS x) t151 ON t1.x = t151.x JOIN (SELECT 1 AS x) t152 ON t1.x = t152.x JOIN (SELECT 1 AS x) t153 ON t1.x = t153.x JOIN (SELECT 1 AS x) t154 ON t1.x = t154.x JOIN (SELECT 1 AS x) t155 ON t1.x = t155.x JOIN (SELECT 1 AS x) t156 ON t1.x = t156.x JOIN (SELECT 1 AS x) t157 ON t1.x = t157.x JOIN (SELECT 1 AS x) t158 ON t1.x = t158.x JOIN (SELECT 1 AS x) t159 ON t1.x = t159.x JOIN (SELECT 1 AS x) t160 ON t1.x = t160.x JOIN (SELECT 1 AS x) t161 ON t1.x = t161.x JOIN (SELECT 1 AS x) t162 ON t1.x = t162.x JOIN (SELECT 1 AS x) t163 ON t1.x = t163.x JOIN (SELECT 1 AS x) t164 ON t1.x = t164.x JOIN (SELECT 1 AS x) t165 ON t1.x = t165.x JOIN (SELECT 1 AS x) t166 ON t1.x = t166.x JOIN (SELECT 1 AS x) t167 ON t1.x = t167.x JOIN (SELECT 1 AS x) t168 ON t1.x = t168.x JOIN (SELECT 1 AS x) t169 ON t1.x = t169.x JOIN (SELECT 1 AS x) t170 ON t1.x = t170.x JOIN (SELECT 1 AS x) t171 ON t1.x = t171.x JOIN (SELECT 1 AS x) t172 ON t1.x = t172.x JOIN (SELECT 1 AS x) t173 ON t1.x = t173.x JOIN (SELECT 1 AS x) t174 ON t1.x = t174.x JOIN (SELECT 1 AS x) t175 ON t1.x = t175.x JOIN (SELECT 1 AS x) t176 ON t1.x = t176.x JOIN (SELECT 1 AS x) t177 ON t1.x = t177.x JOIN (SELECT 1 AS x) t178 ON t1.x = t178.x JOIN (SELECT 1 AS x) t179 ON t1.x = t179.x JOIN (SELECT 1 AS x) t180 ON t1.x = t180.x JOIN (SELECT 1 AS x) t181 ON t1.x = t181.x JOIN (SELECT 1 AS x) t182 ON t1.x = t182.x JOIN (SELECT 1 AS x) t183 ON t1.x = t183.x JOIN (SELECT 1 AS x) t184 ON t1.x = t184.x JOIN (SELECT 1 AS x) t185 ON t1.x = t185.x JOIN (SELECT 1 AS x) t186 ON t1.x = t186.x JOIN (SELECT 1 AS x) t187 ON t1.x = t187.x JOIN (SELECT 1 AS x) t188 ON t1.x = t188.x JOIN (SELECT 1 AS x) t189 ON t1.x = t189.x JOIN (SELECT 1 AS x) t190 ON t1.x = t190.x JOIN (SELECT 1 AS x) t191 ON t1.x = t191.x JOIN (SELECT 1 AS x) t192 ON t1.x = t192.x JOIN (SELECT 1 AS x) t193 ON t1.x = t193.x JOIN (SELECT 1 AS x) t194 ON t1.x = t194.x JOIN (SELECT 1 AS x) t195 ON t1.x = t195.x JOIN (SELECT 1 AS x) t196 ON t1.x = t196.x JOIN (SELECT 1 AS x) t197 ON t1.x = t197.x JOIN (SELECT 1 AS x) t198 ON t1.x = t198.x JOIN (SELECT 1 AS x) t199 ON t1.x = t199.x JOIN (SELECT 1 AS x) t200 ON t1.x = t200.x JOIN (SELECT 1 AS x) t201 ON t1.x = t201.x JOIN (SELECT 1 AS x) t202 ON t1.x = t202.x JOIN (SELECT 1 AS x) t203 ON t1.x = t203.x JOIN (SELECT 1 AS x) t204 ON t1.x = t204.x JOIN (SELECT 1 AS x) t205 ON t1.x = t205.x JOIN (SELECT 1 AS x) t206 ON t1.x = t206.x JOIN (SELECT 1 AS x) t207 ON t1.x = t207.x JOIN (SELECT 1 AS x) t208 ON t1.x = t208.x JOIN (SELECT 1 AS x) t209 ON t1.x = t209.x JOIN (SELECT 1 AS x) t210 ON t1.x = t210.x JOIN (SELECT 1 AS x) t211 ON t1.x = t211.x JOIN (SELECT 1 AS x) t212 ON t1.x = t212.x JOIN (SELECT 1 AS x) t213 ON t1.x = t213.x JOIN (SELECT 1 AS x) t214 ON t1.x = t214.x JOIN (SELECT 1 AS x) t215 ON t1.x = t215.x JOIN (SELECT 1 AS x) t216 ON t1.x = t216.x JOIN (SELECT 1 AS x) t217 ON t1.x = t217.x JOIN (SELECT 1 AS x) t218 ON t1.x = t218.x JOIN (SELECT 1 AS x) t219 ON t1.x = t219.x JOIN (SELECT 1 AS x) t220 ON t1.x = t220.x JOIN (SELECT 1 AS x) t221 ON t1.x = t221.x JOIN (SELECT 1 AS x) t222 ON t1.x = t222.x JOIN (SELECT 1 AS x) t223 ON t1.x = t223.x JOIN (SELECT 1 AS x) t224 ON t1.x = t224.x JOIN (SELECT 1 AS x) t225 ON t1.x = t225.x JOIN (SELECT 1 AS x) t226 ON t1.x = t226.x JOIN (SELECT 1 AS x) t227 ON t1.x = t227.x JOIN (SELECT 1 AS x) t228 ON t1.x = t228.x JOIN (SELECT 1 AS x) t229 ON t1.x = t229.x JOIN (SELECT 1 AS x) t230 ON t1.x = t230.x JOIN (SELECT 1 AS x) t231 ON t1.x = t231.x JOIN (SELECT 1 AS x) t232 ON t1.x = t232.x JOIN (SELECT 1 AS x) t233 ON t1.x = t233.x JOIN (SELECT 1 AS x) t234 ON t1.x = t234.x JOIN (SELECT 1 AS x) t235 ON t1.x = t235.x JOIN (SELECT 1 AS x) t236 ON t1.x = t236.x JOIN (SELECT 1 AS x) t237 ON t1.x = t237.x JOIN (SELECT 1 AS x) t238 ON t1.x = t238.x JOIN (SELECT 1 AS x) t239 ON t1.x = t239.x JOIN (SELECT 1 AS x) t240 ON t1.x = t240.x JOIN (SELECT 1 AS x) t241 ON t1.x = t241.x JOIN (SELECT 1 AS x) t242 ON t1.x = t242.x JOIN (SELECT 1 AS x) t243 ON t1.x = t243.x JOIN (SELECT 1 AS x) t244 ON t1.x = t244.x JOIN (SELECT 1 AS x) t245 ON t1.x = t245.x JOIN (SELECT 1 AS x) t246 ON t1.x = t246.x JOIN (SELECT 1 AS x) t247 ON t1.x = t247.x JOIN (SELECT 1 AS x) t248 ON t1.x = t248.x JOIN (SELECT 1 AS x) t249 ON t1.x = t249.x JOIN (SELECT 1 AS x) t250 ON t1.x = t250.x JOIN (SELECT 1 AS x) t251 ON t1.x = t251.x JOIN (SELECT 1 AS x) t252 ON t1.x = t252.x JOIN (SELECT 1 AS x) t253 ON t1.x = t253.x JOIN (SELECT 1 AS x) t254 ON t1.x = t254.x JOIN (SELECT 1 AS x) t255 ON t1.x = t255.x JOIN (SELECT 1 AS x) t256 ON t1.x = t256.x JOIN (SELECT 1 AS x) t257 ON t1.x = t257.x JOIN (SELECT 1 AS x) t258 ON t1.x = t258.x JOIN (SELECT 1 AS x) t259 ON t1.x = t259.x JOIN (SELECT 1 AS x) t260 ON t1.x = t260.x JOIN (SELECT 1 AS x) t261 ON t1.x = t261.x JOIN (SELECT 1 AS x) t262 ON t1.x = t262.x JOIN (SELECT 1 AS x) t263 ON t1.x = t263.x JOIN (SELECT 1 AS x) t264 ON t1.x = t264.x JOIN (SELECT 1 AS x) t265 ON t1.x = t265.x JOIN (SELECT 1 AS x) t266 ON t1.x = t266.x JOIN (SELECT 1 AS x) t267 ON t1.x = t267.x JOIN (SELECT 1 AS x) t268 ON t1.x = t268.x JOIN (SELECT 1 AS x) t269 ON t1.x = t269.x JOIN (SELECT 1 AS x) t270 ON t1.x = t270.x JOIN (SELECT 1 AS x) t271 ON t1.x = t271.x JOIN (SELECT 1 AS x) t272 ON t1.x = t272.x JOIN (SELECT 1 AS x) t273 ON t1.x = t273.x JOIN (SELECT 1 AS x) t274 ON t1.x = t274.x JOIN (SELECT 1 AS x) t275 ON t1.x = t275.x JOIN (SELECT 1 AS x) t276 ON t1.x = t276.x JOIN (SELECT 1 AS x) t277 ON t1.x = t277.x JOIN (SELECT 1 AS x) t278 ON t1.x = t278.x JOIN (SELECT 1 AS x) t279 ON t1.x = t279.x JOIN (SELECT 1 AS x) t280 ON t1.x = t280.x JOIN (SELECT 1 AS x) t281 ON t1.x = t281.x JOIN (SELECT 1 AS x) t282 ON t1.x = t282.x JOIN (SELECT 1 AS x) t283 ON t1.x = t283.x JOIN (SELECT 1 AS x) t284 ON t1.x = t284.x JOIN (SELECT 1 AS x) t285 ON t1.x = t285.x JOIN (SELECT 1 AS x) t286 ON t1.x = t286.x JOIN (SELECT 1 AS x) t287 ON t1.x = t287.x JOIN (SELECT 1 AS x) t288 ON t1.x = t288.x JOIN (SELECT 1 AS x) t289 ON t1.x = t289.x JOIN (SELECT 1 AS x) t290 ON t1.x = t290.x JOIN (SELECT 1 AS x) t291 ON t1.x = t291.x JOIN (SELECT 1 AS x) t292 ON t1.x = t292.x JOIN (SELECT 1 AS x) t293 ON t1.x = t293.x JOIN (SELECT 1 AS x) t294 ON t1.x = t294.x JOIN (SELECT 1 AS x) t295 ON t1.x = t295.x JOIN (SELECT 1 AS x) t296 ON t1.x = t296.x JOIN (SELECT 1 AS x) t297 ON t1.x = t297.x JOIN (SELECT 1 AS x) t298 ON t1.x = t298.x JOIN (SELECT 1 AS x) t299 ON t1.x = t299.x JOIN (SELECT 1 AS x) t300 ON t1.x = t300.x JOIN (SELECT 1 AS x) t301 ON t1.x = t301.x JOIN (SELECT 1 AS x) t302 ON t1.x = t302.x JOIN (SELECT 1 AS x) t303 ON t1.x = t303.x JOIN (SELECT 1 AS x) t304 ON t1.x = t304.x JOIN (SELECT 1 AS x) t305 ON t1.x = t305.x JOIN (SELECT 1 AS x) t306 ON t1.x = t306.x JOIN (SELECT 1 AS x) t307 ON t1.x = t307.x JOIN (SELECT 1 AS x) t308 ON t1.x = t308.x JOIN (SELECT 1 AS x) t309 ON t1.x = t309.x JOIN (SELECT 1 AS x) t310 ON t1.x = t310.x JOIN (SELECT 1 AS x) t311 ON t1.x = t311.x JOIN (SELECT 1 AS x) t312 ON t1.x = t312.x JOIN (SELECT 1 AS x) t313 ON t1.x = t313.x JOIN (SELECT 1 AS x) t314 ON t1.x = t314.x JOIN (SELECT 1 AS x) t315 ON t1.x = t315.x JOIN (SELECT 1 AS x) t316 ON t1.x = t316.x JOIN (SELECT 1 AS x) t317 ON t1.x = t317.x JOIN (SELECT 1 AS x) t318 ON t1.x = t318.x JOIN (SELECT 1 AS x) t319 ON t1.x = t319.x JOIN (SELECT 1 AS x) t320 ON t1.x = t320.x JOIN (SELECT 1 AS x) t321 ON t1.x = t321.x JOIN (SELECT 1 AS x) t322 ON t1.x = t322.x JOIN (SELECT 1 AS x) t323 ON t1.x = t323.x JOIN (SELECT 1 AS x) t324 ON t1.x = t324.x JOIN (SELECT 1 AS x) t325 ON t1.x = t325.x JOIN (SELECT 1 AS x) t326 ON t1.x = t326.x JOIN (SELECT 1 AS x) t327 ON t1.x = t327.x JOIN (SELECT 1 AS x) t328 ON t1.x = t328.x JOIN (SELECT 1 AS x) t329 ON t1.x = t329.x JOIN (SELECT 1 AS x) t330 ON t1.x = t330.x JOIN (SELECT 1 AS x) t331 ON t1.x = t331.x JOIN (SELECT 1 AS x) t332 ON t1.x = t332.x JOIN (SELECT 1 AS x) t333 ON t1.x = t333.x JOIN (SELECT 1 AS x) t334 ON t1.x = t334.x JOIN (SELECT 1 AS x) t335 ON t1.x = t335.x JOIN (SELECT 1 AS x) t336 ON t1.x = t336.x JOIN (SELECT 1 AS x) t337 ON t1.x = t337.x JOIN (SELECT 1 AS x) t338 ON t1.x = t338.x JOIN (SELECT 1 AS x) t339 ON t1.x = t339.x JOIN (SELECT 1 AS x) t340 ON t1.x = t340.x JOIN (SELECT 1 AS x) t341 ON t1.x = t341.x JOIN (SELECT 1 AS x) t342 ON t1.x = t342.x JOIN (SELECT 1 AS x) t343 ON t1.x = t343.x JOIN (SELECT 1 AS x) t344 ON t1.x = t344.x JOIN (SELECT 1 AS x) t345 ON t1.x = t345.x JOIN (SELECT 1 AS x) t346 ON t1.x = t346.x JOIN (SELECT 1 AS x) t347 ON t1.x = t347.x JOIN (SELECT 1 AS x) t348 ON t1.x = t348.x JOIN (SELECT 1 AS x) t349 ON t1.x = t349.x JOIN (SELECT 1 AS x) t350 ON t1.x = t350.x JOIN (SELECT 1 AS x) t351 ON t1.x = t351.x JOIN (SELECT 1 AS x) t352 ON t1.x = t352.x JOIN (SELECT 1 AS x) t353 ON t1.x = t353.x JOIN (SELECT 1 AS x) t354 ON t1.x = t354.x JOIN (SELECT 1 AS x) t355 ON t1.x = t355.x JOIN (SELECT 1 AS x) t356 ON t1.x = t356.x JOIN (SELECT 1 AS x) t357 ON t1.x = t357.x JOIN (SELECT 1 AS x) t358 ON t1.x = t358.x JOIN (SELECT 1 AS x) t359 ON t1.x = t359.x JOIN (SELECT 1 AS x) t360 ON t1.x = t360.x JOIN (SELECT 1 AS x) t361 ON t1.x = t361.x JOIN (SELECT 1 AS x) t362 ON t1.x = t362.x JOIN (SELECT 1 AS x) t363 ON t1.x = t363.x JOIN (SELECT 1 AS x) t364 ON t1.x = t364.x JOIN (SELECT 1 AS x) t365 ON t1.x = t365.x JOIN (SELECT 1 AS x) t366 ON t1.x = t366.x JOIN (SELECT 1 AS x) t367 ON t1.x = t367.x JOIN (SELECT 1 AS x) t368 ON t1.x = t368.x JOIN (SELECT 1 AS x) t369 ON t1.x = t369.x JOIN (SELECT 1 AS x) t370 ON t1.x = t370.x JOIN (SELECT 1 AS x) t371 ON t1.x = t371.x JOIN (SELECT 1 AS x) t372 ON t1.x = t372.x JOIN (SELECT 1 AS x) t373 ON t1.x = t373.x JOIN (SELECT 1 AS x) t374 ON t1.x = t374.x JOIN (SELECT 1 AS x) t375 ON t1.x = t375.x JOIN (SELECT 1 AS x) t376 ON t1.x = t376.x JOIN (SELECT 1 AS x) t377 ON t1.x = t377.x JOIN (SELECT 1 AS x) t378 ON t1.x = t378.x JOIN (SELECT 1 AS x) t379 ON t1.x = t379.x JOIN (SELECT 1 AS x) t380 ON t1.x = t380.x JOIN (SELECT 1 AS x) t381 ON t1.x = t381.x JOIN (SELECT 1 AS x) t382 ON t1.x = t382.x JOIN (SELECT 1 AS x) t383 ON t1.x = t383.x JOIN (SELECT 1 AS x) t384 ON t1.x = t384.x JOIN (SELECT 1 AS x) t385 ON t1.x = t385.x JOIN (SELECT 1 AS x) t386 ON t1.x = t386.x JOIN (SELECT 1 AS x) t387 ON t1.x = t387.x JOIN (SELECT 1 AS x) t388 ON t1.x = t388.x JOIN (SELECT 1 AS x) t389 ON t1.x = t389.x JOIN (SELECT 1 AS x) t390 ON t1.x = t390.x JOIN (SELECT 1 AS x) t391 ON t1.x = t391.x JOIN (SELECT 1 AS x) t392 ON t1.x = t392.x JOIN (SELECT 1 AS x) t393 ON t1.x = t393.x JOIN (SELECT 1 AS x) t394 ON t1.x = t394.x JOIN (SELECT 1 AS x) t395 ON t1.x = t395.x JOIN (SELECT 1 AS x) t396 ON t1.x = t396.x JOIN (SELECT 1 AS x) t397 ON t1.x = t397.x JOIN (SELECT 1 AS x) t398 ON t1.x = t398.x JOIN (SELECT 1 AS x) t399 ON t1.x = t399.x JOIN (SELECT 1 AS x) t400 ON t1.x = t400.x JOIN (SELECT 1 AS x) t401 ON t1.x = t401.x JOIN (SELECT 1 AS x) t402 ON t1.x = t402.x JOIN (SELECT 1 AS x) t403 ON t1.x = t403.x JOIN (SELECT 1 AS x) t404 ON t1.x = t404.x JOIN (SELECT 1 AS x) t405 ON t1.x = t405.x JOIN (SELECT 1 AS x) t406 ON t1.x = t406.x JOIN (SELECT 1 AS x) t407 ON t1.x = t407.x JOIN (SELECT 1 AS x) t408 ON t1.x = t408.x JOIN (SELECT 1 AS x) t409 ON t1.x = t409.x JOIN (SELECT 1 AS x) t410 ON t1.x = t410.x JOIN (SELECT 1 AS x) t411 ON t1.x = t411.x JOIN (SELECT 1 AS x) t412 ON t1.x = t412.x JOIN (SELECT 1 AS x) t413 ON t1.x = t413.x JOIN (SELECT 1 AS x) t414 ON t1.x = t414.x JOIN (SELECT 1 AS x) t415 ON t1.x = t415.x JOIN (SELECT 1 AS x) t416 ON t1.x = t416.x JOIN (SELECT 1 AS x) t417 ON t1.x = t417.x JOIN (SELECT 1 AS x) t418 ON t1.x = t418.x JOIN (SELECT 1 AS x) t419 ON t1.x = t419.x JOIN (SELECT 1 AS x) t420 ON t1.x = t420.x JOIN (SELECT 1 AS x) t421 ON t1.x = t421.x JOIN (SELECT 1 AS x) t422 ON t1.x = t422.x JOIN (SELECT 1 AS x) t423 ON t1.x = t423.x JOIN (SELECT 1 AS x) t424 ON t1.x = t424.x JOIN (SELECT 1 AS x) t425 ON t1.x = t425.x JOIN (SELECT 1 AS x) t426 ON t1.x = t426.x JOIN (SELECT 1 AS x) t427 ON t1.x = t427.x JOIN (SELECT 1 AS x) t428 ON t1.x = t428.x JOIN (SELECT 1 AS x) t429 ON t1.x = t429.x JOIN (SELECT 1 AS x) t430 ON t1.x = t430.x JOIN (SELECT 1 AS x) t431 ON t1.x = t431.x JOIN (SELECT 1 AS x) t432 ON t1.x = t432.x JOIN (SELECT 1 AS x) t433 ON t1.x = t433.x JOIN (SELECT 1 AS x) t434 ON t1.x = t434.x JOIN (SELECT 1 AS x) t435 ON t1.x = t435.x JOIN (SELECT 1 AS x) t436 ON t1.x = t436.x JOIN (SELECT 1 AS x) t437 ON t1.x = t437.x JOIN (SELECT 1 AS x) t438 ON t1.x = t438.x JOIN (SELECT 1 AS x) t439 ON t1.x = t439.x JOIN (SELECT 1 AS x) t440 ON t1.x = t440.x JOIN (SELECT 1 AS x) t441 ON t1.x = t441.x JOIN (SELECT 1 AS x) t442 ON t1.x = t442.x JOIN (SELECT 1 AS x) t443 ON t1.x = t443.x JOIN (SELECT 1 AS x) t444 ON t1.x = t444.x JOIN (SELECT 1 AS x) t445 ON t1.x = t445.x JOIN (SELECT 1 AS x) t446 ON t1.x = t446.x JOIN (SELECT 1 AS x) t447 ON t1.x = t447.x JOIN (SELECT 1 AS x) t448 ON t1.x = t448.x JOIN (SELECT 1 AS x) t449 ON t1.x = t449.x JOIN (SELECT 1 AS x) t450 ON t1.x = t450.x JOIN (SELECT 1 AS x) t451 ON t1.x = t451.x JOIN (SELECT 1 AS x) t452 ON t1.x = t452.x JOIN (SELECT 1 AS x) t453 ON t1.x = t453.x JOIN (SELECT 1 AS x) t454 ON t1.x = t454.x JOIN (SELECT 1 AS x) t455 ON t1.x = t455.x JOIN (SELECT 1 AS x) t456 ON t1.x = t456.x JOIN (SELECT 1 AS x) t457 ON t1.x = t457.x JOIN (SELECT 1 AS x) t458 ON t1.x = t458.x JOIN (SELECT 1 AS x) t459 ON t1.x = t459.x JOIN (SELECT 1 AS x) t460 ON t1.x = t460.x JOIN (SELECT 1 AS x) t461 ON t1.x = t461.x JOIN (SELECT 1 AS x) t462 ON t1.x = t462.x JOIN (SELECT 1 AS x) t463 ON t1.x = t463.x JOIN (SELECT 1 AS x) t464 ON t1.x = t464.x JOIN (SELECT 1 AS x) t465 ON t1.x = t465.x JOIN (SELECT 1 AS x) t466 ON t1.x = t466.x JOIN (SELECT 1 AS x) t467 ON t1.x = t467.x JOIN (SELECT 1 AS x) t468 ON t1.x = t468.x JOIN (SELECT 1 AS x) t469 ON t1.x = t469.x JOIN (SELECT 1 AS x) t470 ON t1.x = t470.x JOIN (SELECT 1 AS x) t471 ON t1.x = t471.x JOIN (SELECT 1 AS x) t472 ON t1.x = t472.x JOIN (SELECT 1 AS x) t473 ON t1.x = t473.x JOIN (SELECT 1 AS x) t474 ON t1.x = t474.x JOIN (SELECT 1 AS x) t475 ON t1.x = t475.x JOIN (SELECT 1 AS x) t476 ON t1.x = t476.x JOIN (SELECT 1 AS x) t477 ON t1.x = t477.x JOIN (SELECT 1 AS x) t478 ON t1.x = t478.x JOIN (SELECT 1 AS x) t479 ON t1.x = t479.x JOIN (SELECT 1 AS x) t480 ON t1.x = t480.x JOIN (SELECT 1 AS x) t481 ON t1.x = t481.x JOIN (SELECT 1 AS x) t482 ON t1.x = t482.x JOIN (SELECT 1 AS x) t483 ON t1.x = t483.x JOIN (SELECT 1 AS x) t484 ON t1.x = t484.x JOIN (SELECT 1 AS x) t485 ON t1.x = t485.x JOIN (SELECT 1 AS x) t486 ON t1.x = t486.x JOIN (SELECT 1 AS x) t487 ON t1.x = t487.x JOIN (SELECT 1 AS x) t488 ON t1.x = t488.x JOIN (SELECT 1 AS x) t489 ON t1.x = t489.x JOIN (SELECT 1 AS x) t490 ON t1.x = t490.x JOIN (SELECT 1 AS x) t491 ON t1.x = t491.x JOIN (SELECT 1 AS x) t492 ON t1.x = t492.x JOIN (SELECT 1 AS x) t493 ON t1.x = t493.x JOIN (SELECT 1 AS x) t494 ON t1.x = t494.x JOIN (SELECT 1 AS x) t495 ON t1.x = t495.x JOIN (SELECT 1 AS x) t496 ON t1.x = t496.x JOIN (SELECT 1 AS x) t497 ON t1.x = t497.x JOIN (SELECT 1 AS x) t498 ON t1.x = t498.x JOIN (SELECT 1 AS x) t499 ON t1.x = t499.x JOIN (SELECT 1 AS x) t500 ON t1.x = t500.x JOIN (SELECT 1 AS x) t501 ON t1.x = t501.x JOIN (SELECT 1 AS x) t502 ON t1.x = t502.x JOIN (SELECT 1 AS x) t503 ON t1.x = t503.x JOIN (SELECT 1 AS x) t504 ON t1.x = t504.x JOIN (SELECT 1 AS x) t505 ON t1.x = t505.x JOIN (SELECT 1 AS x) t506 ON t1.x = t506.x JOIN (SELECT 1 AS x) t507 ON t1.x = t507.x JOIN (SELECT 1 AS x) t508 ON t1.x = t508.x JOIN (SELECT 1 AS x) t509 ON t1.x = t509.x JOIN (SELECT 1 AS x) t510 ON t1.x = t510.x JOIN (SELECT 1 AS x) t511 ON t1.x = t511.x JOIN (SELECT 1 AS x) t512 ON t1.x = t512.x JOIN (SELECT 1 AS x) t513 ON t1.x = t513.x JOIN (SELECT 1 AS x) t514 ON t1.x = t514.x JOIN (SELECT 1 AS x) t515 ON t1.x = t515.x JOIN (SELECT 1 AS x) t516 ON t1.x = t516.x JOIN (SELECT 1 AS x) t517 ON t1.x = t517.x JOIN (SELECT 1 AS x) t518 ON t1.x = t518.x JOIN (SELECT 1 AS x) t519 ON t1.x = t519.x JOIN (SELECT 1 AS x) t520 ON t1.x = t520.x JOIN (SELECT 1 AS x) t521 ON t1.x = t521.x JOIN (SELECT 1 AS x) t522 ON t1.x = t522.x JOIN (SELECT 1 AS x) t523 ON t1.x = t523.x JOIN (SELECT 1 AS x) t524 ON t1.x = t524.x JOIN (SELECT 1 AS x) t525 ON t1.x = t525.x JOIN (SELECT 1 AS x) t526 ON t1.x = t526.x JOIN (SELECT 1 AS x) t527 ON t1.x = t527.x JOIN (SELECT 1 AS x) t528 ON t1.x = t528.x JOIN (SELECT 1 AS x) t529 ON t1.x = t529.x JOIN (SELECT 1 AS x) t530 ON t1.x = t530.x JOIN (SELECT 1 AS x) t531 ON t1.x = t531.x JOIN (SELECT 1 AS x) t532 ON t1.x = t532.x JOIN (SELECT 1 AS x) t533 ON t1.x = t533.x JOIN (SELECT 1 AS x) t534 ON t1.x = t534.x JOIN (SELECT 1 AS x) t535 ON t1.x = t535.x JOIN (SELECT 1 AS x) t536 ON t1.x = t536.x JOIN (SELECT 1 AS x) t537 ON t1.x = t537.x JOIN (SELECT 1 AS x) t538 ON t1.x = t538.x JOIN (SELECT 1 AS x) t539 ON t1.x = t539.x JOIN (SELECT 1 AS x) t540 ON t1.x = t540.x JOIN (SELECT 1 AS x) t541 ON t1.x = t541.x JOIN (SELECT 1 AS x) t542 ON t1.x = t542.x JOIN (SELECT 1 AS x) t543 ON t1.x = t543.x JOIN (SELECT 1 AS x) t544 ON t1.x = t544.x JOIN (SELECT 1 AS x) t545 ON t1.x = t545.x JOIN (SELECT 1 AS x) t546 ON t1.x = t546.x JOIN (SELECT 1 AS x) t547 ON t1.x = t547.x JOIN (SELECT 1 AS x) t548 ON t1.x = t548.x JOIN (SELECT 1 AS x) t549 ON t1.x = t549.x JOIN (SELECT 1 AS x) t550 ON t1.x = t550.x JOIN (SELECT 1 AS x) t551 ON t1.x = t551.x JOIN (SELECT 1 AS x) t552 ON t1.x = t552.x JOIN (SELECT 1 AS x) t553 ON t1.x = t553.x JOIN (SELECT 1 AS x) t554 ON t1.x = t554.x JOIN (SELECT 1 AS x) t555 ON t1.x = t555.x JOIN (SELECT 1 AS x) t556 ON t1.x = t556.x JOIN (SELECT 1 AS x) t557 ON t1.x = t557.x JOIN (SELECT 1 AS x) t558 ON t1.x = t558.x JOIN (SELECT 1 AS x) t559 ON t1.x = t559.x JOIN (SELECT 1 AS x) t560 ON t1.x = t560.x JOIN (SELECT 1 AS x) t561 ON t1.x = t561.x JOIN (SELECT 1 AS x) t562 ON t1.x = t562.x JOIN (SELECT 1 AS x) t563 ON t1.x = t563.x JOIN (SELECT 1 AS x) t564 ON t1.x = t564.x JOIN (SELECT 1 AS x) t565 ON t1.x = t565.x JOIN (SELECT 1 AS x) t566 ON t1.x = t566.x JOIN (SELECT 1 AS x) t567 ON t1.x = t567.x JOIN (SELECT 1 AS x) t568 ON t1.x = t568.x JOIN (SELECT 1 AS x) t569 ON t1.x = t569.x JOIN (SELECT 1 AS x) t570 ON t1.x = t570.x JOIN (SELECT 1 AS x) t571 ON t1.x = t571.x JOIN (SELECT 1 AS x) t572 ON t1.x = t572.x JOIN (SELECT 1 AS x) t573 ON t1.x = t573.x JOIN (SELECT 1 AS x) t574 ON t1.x = t574.x JOIN (SELECT 1 AS x) t575 ON t1.x = t575.x JOIN (SELECT 1 AS x) t576 ON t1.x = t576.x JOIN (SELECT 1 AS x) t577 ON t1.x = t577.x JOIN (SELECT 1 AS x) t578 ON t1.x = t578.x JOIN (SELECT 1 AS x) t579 ON t1.x = t579.x JOIN (SELECT 1 AS x) t580 ON t1.x = t580.x JOIN (SELECT 1 AS x) t581 ON t1.x = t581.x JOIN (SELECT 1 AS x) t582 ON t1.x = t582.x JOIN (SELECT 1 AS x) t583 ON t1.x = t583.x JOIN (SELECT 1 AS x) t584 ON t1.x = t584.x JOIN (SELECT 1 AS x) t585 ON t1.x = t585.x JOIN (SELECT 1 AS x) t586 ON t1.x = t586.x JOIN (SELECT 1 AS x) t587 ON t1.x = t587.x JOIN (SELECT 1 AS x) t588 ON t1.x = t588.x JOIN (SELECT 1 AS x) t589 ON t1.x = t589.x JOIN (SELECT 1 AS x) t590 ON t1.x = t590.x JOIN (SELECT 1 AS x) t591 ON t1.x = t591.x JOIN (SELECT 1 AS x) t592 ON t1.x = t592.x JOIN (SELECT 1 AS x) t593 ON t1.x = t593.x JOIN (SELECT 1 AS x) t594 ON t1.x = t594.x JOIN (SELECT 1 AS x) t595 ON t1.x = t595.x JOIN (SELECT 1 AS x) t596 ON t1.x = t596.x JOIN (SELECT 1 AS x) t597 ON t1.x = t597.x JOIN (SELECT 1 AS x) t598 ON t1.x = t598.x JOIN (SELECT 1 AS x) t599 ON t1.x = t599.x JOIN (SELECT 1 AS x) t600 ON t1.x = t600.x JOIN (SELECT 1 AS x) t601 ON t1.x = t601.x JOIN (SELECT 1 AS x) t602 ON t1.x = t602.x JOIN (SELECT 1 AS x) t603 ON t1.x = t603.x JOIN (SELECT 1 AS x) t604 ON t1.x = t604.x JOIN (SELECT 1 AS x) t605 ON t1.x = t605.x JOIN (SELECT 1 AS x) t606 ON t1.x = t606.x JOIN (SELECT 1 AS x) t607 ON t1.x = t607.x JOIN (SELECT 1 AS x) t608 ON t1.x = t608.x JOIN (SELECT 1 AS x) t609 ON t1.x = t609.x JOIN (SELECT 1 AS x) t610 ON t1.x = t610.x JOIN (SELECT 1 AS x) t611 ON t1.x = t611.x JOIN (SELECT 1 AS x) t612 ON t1.x = t612.x JOIN (SELECT 1 AS x) t613 ON t1.x = t613.x JOIN (SELECT 1 AS x) t614 ON t1.x = t614.x JOIN (SELECT 1 AS x) t615 ON t1.x = t615.x JOIN (SELECT 1 AS x) t616 ON t1.x = t616.x JOIN (SELECT 1 AS x) t617 ON t1.x = t617.x JOIN (SELECT 1 AS x) t618 ON t1.x = t618.x JOIN (SELECT 1 AS x) t619 ON t1.x = t619.x JOIN (SELECT 1 AS x) t620 ON t1.x = t620.x JOIN (SELECT 1 AS x) t621 ON t1.x = t621.x JOIN (SELECT 1 AS x) t622 ON t1.x = t622.x JOIN (SELECT 1 AS x) t623 ON t1.x = t623.x JOIN (SELECT 1 AS x) t624 ON t1.x = t624.x JOIN (SELECT 1 AS x) t625 ON t1.x = t625.x JOIN (SELECT 1 AS x) t626 ON t1.x = t626.x JOIN (SELECT 1 AS x) t627 ON t1.x = t627.x JOIN (SELECT 1 AS x) t628 ON t1.x = t628.x JOIN (SELECT 1 AS x) t629 ON t1.x = t629.x JOIN (SELECT 1 AS x) t630 ON t1.x = t630.x JOIN (SELECT 1 AS x) t631 ON t1.x = t631.x JOIN (SELECT 1 AS x) t632 ON t1.x = t632.x JOIN (SELECT 1 AS x) t633 ON t1.x = t633.x JOIN (SELECT 1 AS x) t634 ON t1.x = t634.x JOIN (SELECT 1 AS x) t635 ON t1.x = t635.x JOIN (SELECT 1 AS x) t636 ON t1.x = t636.x JOIN (SELECT 1 AS x) t637 ON t1.x = t637.x JOIN (SELECT 1 AS x) t638 ON t1.x = t638.x JOIN (SELECT 1 AS x) t639 ON t1.x = t639.x JOIN (SELECT 1 AS x) t640 ON t1.x = t640.x JOIN (SELECT 1 AS x) t641 ON t1.x = t641.x JOIN (SELECT 1 AS x) t642 ON t1.x = t642.x JOIN (SELECT 1 AS x) t643 ON t1.x = t643.x JOIN (SELECT 1 AS x) t644 ON t1.x = t644.x JOIN (SELECT 1 AS x) t645 ON t1.x = t645.x JOIN (SELECT 1 AS x) t646 ON t1.x = t646.x JOIN (SELECT 1 AS x) t647 ON t1.x = t647.x JOIN (SELECT 1 AS x) t648 ON t1.x = t648.x JOIN (SELECT 1 AS x) t649 ON t1.x = t649.x JOIN (SELECT 1 AS x) t650 ON t1.x = t650.x JOIN (SELECT 1 AS x) t651 ON t1.x = t651.x JOIN (SELECT 1 AS x) t652 ON t1.x = t652.x JOIN (SELECT 1 AS x) t653 ON t1.x = t653.x JOIN (SELECT 1 AS x) t654 ON t1.x = t654.x JOIN (SELECT 1 AS x) t655 ON t1.x = t655.x JOIN (SELECT 1 AS x) t656 ON t1.x = t656.x JOIN (SELECT 1 AS x) t657 ON t1.x = t657.x JOIN (SELECT 1 AS x) t658 ON t1.x = t658.x JOIN (SELECT 1 AS x) t659 ON t1.x = t659.x JOIN (SELECT 1 AS x) t660 ON t1.x = t660.x JOIN (SELECT 1 AS x) t661 ON t1.x = t661.x JOIN (SELECT 1 AS x) t662 ON t1.x = t662.x JOIN (SELECT 1 AS x) t663 ON t1.x = t663.x JOIN (SELECT 1 AS x) t664 ON t1.x = t664.x JOIN (SELECT 1 AS x) t665 ON t1.x = t665.x JOIN (SELECT 1 AS x) t666 ON t1.x = t666.x
diff --git a/tests/queries/0_stateless/03130_convert_outer_join_to_inner_join.reference b/tests/queries/0_stateless/03130_convert_outer_join_to_inner_join.reference
index 5fde4f80c5d..d35bdeff98b 100644
--- a/tests/queries/0_stateless/03130_convert_outer_join_to_inner_join.reference
+++ b/tests/queries/0_stateless/03130_convert_outer_join_to_inner_join.reference
@@ -5,18 +5,18 @@ Header: id UInt64
rhs.value String
Actions: INPUT : 0 -> __table1.id UInt64 : 0
INPUT : 1 -> __table1.value String : 1
- INPUT : 2 -> __table2.id UInt64 : 2
- INPUT : 3 -> __table2.value String : 3
+ INPUT : 2 -> __table2.value String : 2
+ INPUT : 3 -> __table2.id UInt64 : 3
ALIAS __table1.id :: 0 -> id UInt64 : 4
ALIAS __table1.value :: 1 -> value String : 0
- ALIAS __table2.id :: 2 -> rhs.id UInt64 : 1
- ALIAS __table2.value :: 3 -> rhs.value String : 2
-Positions: 4 0 1 2
+ ALIAS __table2.value :: 2 -> rhs.value String : 1
+ ALIAS __table2.id :: 3 -> rhs.id UInt64 : 2
+Positions: 4 0 2 1
Join (JOIN FillRightFirst)
Header: __table1.id UInt64
__table1.value String
- __table2.id UInt64
__table2.value String
+ __table2.id UInt64
Type: INNER
Strictness: ALL
Algorithm: HashJoin
@@ -75,18 +75,18 @@ Header: id UInt64
rhs.value String
Actions: INPUT : 0 -> __table1.id UInt64 : 0
INPUT : 1 -> __table1.value String : 1
- INPUT : 2 -> __table2.id UInt64 : 2
- INPUT : 3 -> __table2.value String : 3
+ INPUT : 2 -> __table2.value String : 2
+ INPUT : 3 -> __table2.id UInt64 : 3
ALIAS __table1.id :: 0 -> id UInt64 : 4
ALIAS __table1.value :: 1 -> value String : 0
- ALIAS __table2.id :: 2 -> rhs.id UInt64 : 1
- ALIAS __table2.value :: 3 -> rhs.value String : 2
-Positions: 4 0 1 2
+ ALIAS __table2.value :: 2 -> rhs.value String : 1
+ ALIAS __table2.id :: 3 -> rhs.id UInt64 : 2
+Positions: 4 0 2 1
Join (JOIN FillRightFirst)
Header: __table1.id UInt64
__table1.value String
- __table2.id UInt64
__table2.value String
+ __table2.id UInt64
Type: INNER
Strictness: ALL
Algorithm: HashJoin
@@ -145,18 +145,18 @@ Header: id UInt64
rhs.value String
Actions: INPUT : 0 -> __table1.id UInt64 : 0
INPUT : 1 -> __table1.value String : 1
- INPUT : 2 -> __table2.id UInt64 : 2
- INPUT : 3 -> __table2.value String : 3
+ INPUT : 2 -> __table2.value String : 2
+ INPUT : 3 -> __table2.id UInt64 : 3
ALIAS __table1.id :: 0 -> id UInt64 : 4
ALIAS __table1.value :: 1 -> value String : 0
- ALIAS __table2.id :: 2 -> rhs.id UInt64 : 1
- ALIAS __table2.value :: 3 -> rhs.value String : 2
-Positions: 4 0 1 2
+ ALIAS __table2.value :: 2 -> rhs.value String : 1
+ ALIAS __table2.id :: 3 -> rhs.id UInt64 : 2
+Positions: 4 0 2 1
Join (JOIN FillRightFirst)
Header: __table1.id UInt64
__table1.value String
- __table2.id UInt64
__table2.value String
+ __table2.id UInt64
Type: INNER
Strictness: ALL
Algorithm: HashJoin
diff --git a/tests/queries/0_stateless/03130_convert_outer_join_to_inner_join.sql b/tests/queries/0_stateless/03130_convert_outer_join_to_inner_join.sql
index ddefc322b4f..b3d1827d98f 100644
--- a/tests/queries/0_stateless/03130_convert_outer_join_to_inner_join.sql
+++ b/tests/queries/0_stateless/03130_convert_outer_join_to_inner_join.sql
@@ -22,10 +22,7 @@ SETTINGS index_granularity = 16
INSERT INTO test_table_1 VALUES (1, 'Value_1'), (2, 'Value_2');
INSERT INTO test_table_2 VALUES (2, 'Value_2'), (3, 'Value_3');
-
-EXPLAIN header = 1, actions = 1 SELECT * FROM test_table_1 AS lhs LEFT JOIN test_table_2 AS rhs ON lhs.id = rhs.id WHERE rhs.id != 0
-SETTINGS query_plan_join_inner_table_selection = 'right'
-;
+EXPLAIN header = 1, actions = 1 SELECT * FROM test_table_1 AS lhs LEFT JOIN test_table_2 AS rhs ON lhs.id = rhs.id WHERE rhs.id != 0;
SELECT '--';
@@ -33,9 +30,7 @@ SELECT * FROM test_table_1 AS lhs LEFT JOIN test_table_2 AS rhs ON lhs.id = rhs.
SELECT '--';
-EXPLAIN header = 1, actions = 1 SELECT * FROM test_table_1 AS lhs RIGHT JOIN test_table_2 AS rhs ON lhs.id = rhs.id WHERE lhs.id != 0
-SETTINGS query_plan_join_inner_table_selection = 'right'
-;
+EXPLAIN header = 1, actions = 1 SELECT * FROM test_table_1 AS lhs RIGHT JOIN test_table_2 AS rhs ON lhs.id = rhs.id WHERE lhs.id != 0;
SELECT '--';
@@ -43,9 +38,7 @@ SELECT * FROM test_table_1 AS lhs RIGHT JOIN test_table_2 AS rhs ON lhs.id = rhs
SELECT '--';
-EXPLAIN header = 1, actions = 1 SELECT * FROM test_table_1 AS lhs FULL JOIN test_table_2 AS rhs ON lhs.id = rhs.id WHERE lhs.id != 0 AND rhs.id != 0
-SETTINGS query_plan_join_inner_table_selection = 'right'
-;
+EXPLAIN header = 1, actions = 1 SELECT * FROM test_table_1 AS lhs FULL JOIN test_table_2 AS rhs ON lhs.id = rhs.id WHERE lhs.id != 0 AND rhs.id != 0;
SELECT '--';
diff --git a/tests/queries/0_stateless/03152_join_filter_push_down_equivalent_columns.reference b/tests/queries/0_stateless/03152_join_filter_push_down_equivalent_columns.reference
index 1c82e76cc65..7058d36aaf9 100644
--- a/tests/queries/0_stateless/03152_join_filter_push_down_equivalent_columns.reference
+++ b/tests/queries/0_stateless/03152_join_filter_push_down_equivalent_columns.reference
@@ -65,7 +65,8 @@ SELECT name FROM users RIGHT JOIN users2 USING name WHERE users2.name ='Alice';
Expression ((Project names + (Projection + )))
Header: name String
Join (JOIN FillRightFirst)
- Header: __table2.name String
+ Header: __table1.name String
+ __table2.name String
Filter (( + Change column names to column identifiers))
Header: __table1.name String
ReadFromMergeTree (default.users)
diff --git a/tests/queries/0_stateless/03236_squashing_high_memory.sql b/tests/queries/0_stateless/03236_squashing_high_memory.sql
index eeb3ae85e84..f6e5dbdef03 100644
--- a/tests/queries/0_stateless/03236_squashing_high_memory.sql
+++ b/tests/queries/0_stateless/03236_squashing_high_memory.sql
@@ -11,7 +11,6 @@ CREATE TABLE id_values ENGINE MergeTree ORDER BY id1 AS
SELECT arrayJoin(range(500000)) AS id1, arrayJoin(range(1000)) AS id2;
SET max_memory_usage = '1G';
-SET query_plan_join_inner_table_selection = 'right';
CREATE TABLE test_table ENGINE MergeTree ORDER BY id AS
SELECT id_values.id1 AS id,
diff --git a/tests/queries/0_stateless/03258_multiple_array_joins.reference b/tests/queries/0_stateless/03258_multiple_array_joins.reference
new file mode 100644
index 00000000000..4d357c8ac80
--- /dev/null
+++ b/tests/queries/0_stateless/03258_multiple_array_joins.reference
@@ -0,0 +1,8 @@
+1 Michel Foucault alive no
+1 Michel Foucault profession philosopher
+1 Thomas Aquinas alive no
+1 Thomas Aquinas profession philosopher
+2 Nicola Tesla alive no
+2 Nicola Tesla profession inventor
+2 Thomas Edison alive no
+2 Thomas Edison profession inventor
diff --git a/tests/queries/0_stateless/03258_multiple_array_joins.sql b/tests/queries/0_stateless/03258_multiple_array_joins.sql
new file mode 100644
index 00000000000..ddfac1da080
--- /dev/null
+++ b/tests/queries/0_stateless/03258_multiple_array_joins.sql
@@ -0,0 +1,25 @@
+SET enable_analyzer = 1;
+DROP TABLE IF EXISTS test_multiple_array_join;
+
+CREATE TABLE test_multiple_array_join (
+ id UInt64,
+ person Nested (
+ name String,
+ surname String
+ ),
+ properties Nested (
+ key String,
+ value String
+ )
+) Engine=MergeTree ORDER BY id;
+
+INSERT INTO test_multiple_array_join VALUES (1, ['Thomas', 'Michel'], ['Aquinas', 'Foucault'], ['profession', 'alive'], ['philosopher', 'no']);
+INSERT INTO test_multiple_array_join VALUES (2, ['Thomas', 'Nicola'], ['Edison', 'Tesla'], ['profession', 'alive'], ['inventor', 'no']);
+
+SELECT *
+FROM test_multiple_array_join
+ARRAY JOIN person
+ARRAY JOIN properties
+ORDER BY ALL;
+
+DROP TABLE test_multiple_array_join;
diff --git a/tests/queries/0_stateless/03258_quantile_exact_weighted_issue.reference b/tests/queries/0_stateless/03258_quantile_exact_weighted_issue.reference
new file mode 100644
index 00000000000..69afec5d545
--- /dev/null
+++ b/tests/queries/0_stateless/03258_quantile_exact_weighted_issue.reference
@@ -0,0 +1,2 @@
+AggregateFunction(quantilesExactWeighted(0.2, 0.4, 0.6, 0.8), UInt64, UInt8)
+AggregateFunction(quantilesExactWeightedInterpolated(0.2, 0.4, 0.6, 0.8), UInt64, UInt8)
diff --git a/tests/queries/0_stateless/03258_quantile_exact_weighted_issue.sql b/tests/queries/0_stateless/03258_quantile_exact_weighted_issue.sql
new file mode 100644
index 00000000000..3069389f4e2
--- /dev/null
+++ b/tests/queries/0_stateless/03258_quantile_exact_weighted_issue.sql
@@ -0,0 +1,2 @@
+SELECT toTypeName(quantilesExactWeightedState(0.2, 0.4, 0.6, 0.8)(number + 1, 1) AS x) FROM numbers(49999);
+SELECT toTypeName(quantilesExactWeightedInterpolatedState(0.2, 0.4, 0.6, 0.8)(number + 1, 1) AS x) FROM numbers(49999);
diff --git a/tests/queries/0_stateless/03261_sort_cursor_crash.reference b/tests/queries/0_stateless/03261_sort_cursor_crash.reference
new file mode 100644
index 00000000000..7299f2f5a5f
--- /dev/null
+++ b/tests/queries/0_stateless/03261_sort_cursor_crash.reference
@@ -0,0 +1,4 @@
+42
+43
+44
+45
diff --git a/tests/queries/0_stateless/03261_sort_cursor_crash.sql b/tests/queries/0_stateless/03261_sort_cursor_crash.sql
new file mode 100644
index 00000000000..b659f3d4a92
--- /dev/null
+++ b/tests/queries/0_stateless/03261_sort_cursor_crash.sql
@@ -0,0 +1,24 @@
+-- https://github.com/ClickHouse/ClickHouse/issues/70779
+-- Crash in SortCursorImpl with the old analyzer, which produces a block with 0 columns and 1 row
+DROP TABLE IF EXISTS t0;
+DROP TABLE IF EXISTS t1;
+
+CREATE TABLE t0 (c0 Int) ENGINE = AggregatingMergeTree() ORDER BY tuple();
+INSERT INTO TABLE t0 (c0) VALUES (1);
+SELECT 42 FROM t0 FINAL PREWHERE t0.c0 = 1;
+DROP TABLE t0;
+
+CREATE TABLE t0 (c0 Int) ENGINE = SummingMergeTree() ORDER BY tuple();
+INSERT INTO TABLE t0 (c0) VALUES (1);
+SELECT 43 FROM t0 FINAL PREWHERE t0.c0 = 1;
+DROP TABLE t0;
+
+CREATE TABLE t0 (c0 Int) ENGINE = ReplacingMergeTree() ORDER BY tuple();
+INSERT INTO TABLE t0 (c0) VALUES (1);
+SELECT 44 FROM t0 FINAL PREWHERE t0.c0 = 1;
+DROP TABLE t0;
+
+CREATE TABLE t1 (a0 UInt8, c0 Int32, c1 UInt8) ENGINE = AggregatingMergeTree() ORDER BY tuple();
+INSERT INTO TABLE t1 (a0, c0, c1) VALUES (1, 1, 1);
+SELECT 45 FROM t1 FINAL PREWHERE t1.c0 = t1.c1;
+DROP TABLE t1;
diff --git a/tests/queries/0_stateless/03261_tuple_map_object_to_json_cast.reference b/tests/queries/0_stateless/03261_tuple_map_object_to_json_cast.reference
new file mode 100644
index 00000000000..0ae94e68663
--- /dev/null
+++ b/tests/queries/0_stateless/03261_tuple_map_object_to_json_cast.reference
@@ -0,0 +1,23 @@
+Map to JSON
+{"a":"0","b":"1970-01-01","c":[],"d":[{"e":"0"}]} {'a':'Int64','b':'Date','c':'Array(Nullable(String))','d':'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'}
+{"a":"1","b":"1970-01-02","c":["0"],"d":[{"e":"1"}]} {'a':'Int64','b':'Date','c':'Array(Nullable(String))','d':'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'}
+{"a":"2","b":"1970-01-03","c":["0","1"],"d":[{"e":"2"}]} {'a':'Int64','b':'Date','c':'Array(Nullable(String))','d':'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'}
+{"a":"3","b":"1970-01-04","c":["0","1","2"],"d":[{"e":"3"}]} {'a':'Int64','b':'Date','c':'Array(Nullable(String))','d':'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'}
+{"a":"4","b":"1970-01-05","c":["0","1","2","3"],"d":[{"e":"4"}]} {'a':'Int64','b':'Date','c':'Array(Nullable(String))','d':'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'}
+{"a0":"0","b0":"1970-01-01","c0":[],"d0":[{"e0":"0"}]} {'a0':'Int64','b0':'Date','c0':'Array(Nullable(String))','d0':'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'}
+{"a1":"1","b1":"1970-01-02","c1":["0"],"d1":[{"e1":"1"}]} {'a1':'Int64','b1':'Date','c1':'Array(Nullable(String))','d1':'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'}
+{"a2":"2","b2":"1970-01-03","c2":["0","1"],"d2":[{"e2":"2"}]} {'a2':'Int64','b2':'Date','c2':'Array(Nullable(String))','d2':'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'}
+{"a0":"3","b0":"1970-01-04","c0":["0","1","2"],"d0":[{"e0":"3"}]} {'a0':'Int64','b0':'Date','c0':'Array(Nullable(String))','d0':'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'}
+{"a1":"4","b1":"1970-01-05","c1":["0","1","2","3"],"d1":[{"e1":"4"}]} {'a1':'Int64','b1':'Date','c1':'Array(Nullable(String))','d1':'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'}
+Tuple to JSON
+{"a":"0","b":"1970-01-01","c":[],"d":[{"e":"0"}]} {'a':'Int64','b':'Date','c':'Array(Nullable(String))','d':'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'}
+{"a":"1","b":"1970-01-02","c":["0"],"d":[{"e":"1"}]} {'a':'Int64','b':'Date','c':'Array(Nullable(String))','d':'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'}
+{"a":"2","b":"1970-01-03","c":["0","1"],"d":[{"e":"2"}]} {'a':'Int64','b':'Date','c':'Array(Nullable(String))','d':'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'}
+{"a":"3","b":"1970-01-04","c":["0","1","2"],"d":[{"e":"3"}]} {'a':'Int64','b':'Date','c':'Array(Nullable(String))','d':'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'}
+{"a":"4","b":"1970-01-05","c":["0","1","2","3"],"d":[{"e":"4"}]} {'a':'Int64','b':'Date','c':'Array(Nullable(String))','d':'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'}
+Object to JSON
+{"a":"0","b":"1970-01-01","c":[],"d":{"e":["0"]}} {'a':'Int64','b':'Date','c':'Array(Nullable(String))','d.e':'Array(Nullable(Int64))'}
+{"a":"1","b":"1970-01-02","c":["0"],"d":{"e":["1"]}} {'a':'Int64','b':'Date','c':'Array(Nullable(String))','d.e':'Array(Nullable(Int64))'}
+{"a":"2","b":"1970-01-03","c":["0","1"],"d":{"e":["2"]}} {'a':'Int64','b':'Date','c':'Array(Nullable(String))','d.e':'Array(Nullable(Int64))'}
+{"a":"3","b":"1970-01-04","c":["0","1","2"],"d":{"e":["3"]}} {'a':'Int64','b':'Date','c':'Array(Nullable(String))','d.e':'Array(Nullable(Int64))'}
+{"a":"4","b":"1970-01-05","c":["0","1","2","3"],"d":{"e":["4"]}} {'a':'Int64','b':'Date','c':'Array(Nullable(String))','d.e':'Array(Nullable(Int64))'}
diff --git a/tests/queries/0_stateless/03261_tuple_map_object_to_json_cast.sql b/tests/queries/0_stateless/03261_tuple_map_object_to_json_cast.sql
new file mode 100644
index 00000000000..2e5cecaf502
--- /dev/null
+++ b/tests/queries/0_stateless/03261_tuple_map_object_to_json_cast.sql
@@ -0,0 +1,18 @@
+-- Tags: no-fasttest
+
+set allow_experimental_json_type = 1;
+set allow_experimental_object_type = 1;
+set allow_experimental_variant_type = 1;
+set use_variant_as_common_type = 1;
+set enable_named_columns_in_function_tuple = 1;
+set enable_analyzer = 1;
+
+select 'Map to JSON';
+select map('a', number::UInt32, 'b', toDate(number), 'c', range(number), 'd', [map('e', number::UInt32)])::JSON as json, JSONAllPathsWithTypes(json) from numbers(5);
+select map('a' || number % 3, number::UInt32, 'b' || number % 3, toDate(number), 'c' || number % 3, range(number), 'd' || number % 3, [map('e' || number % 3, number::UInt32)])::JSON as json, JSONAllPathsWithTypes(json) from numbers(5);
+
+select 'Tuple to JSON';
+select tuple(number::UInt32 as a, toDate(number) as b, range(number) as c, [tuple(number::UInt32 as e)] as d)::JSON as json, JSONAllPathsWithTypes(json) from numbers(5);
+
+select 'Object to JSON';
+select toJSONString(map('a', number::UInt32, 'b', toDate(number), 'c', range(number), 'd', [map('e', number::UInt32)]))::Object('json')::JSON as json, JSONAllPathsWithTypes(json) from numbers(5);
diff --git a/tests/queries/0_stateless/03262_system_functions_should_not_fill_query_log_functions.reference b/tests/queries/0_stateless/03262_system_functions_should_not_fill_query_log_functions.reference
new file mode 100644
index 00000000000..021c06382c8
--- /dev/null
+++ b/tests/queries/0_stateless/03262_system_functions_should_not_fill_query_log_functions.reference
@@ -0,0 +1 @@
+[] ['equals'] []
diff --git a/tests/queries/0_stateless/03262_system_functions_should_not_fill_query_log_functions.sql b/tests/queries/0_stateless/03262_system_functions_should_not_fill_query_log_functions.sql
new file mode 100644
index 00000000000..7e6f384c0a8
--- /dev/null
+++ b/tests/queries/0_stateless/03262_system_functions_should_not_fill_query_log_functions.sql
@@ -0,0 +1,9 @@
+SELECT * FROM system.functions WHERE name = 'bitShiftLeft' format Null;
+SYSTEM FLUSH LOGS;
+SELECT used_aggregate_functions, used_functions, used_table_functions
+FROM system.query_log
+WHERE
+ event_date >= yesterday()
+ AND type = 'QueryFinish'
+ AND current_database = currentDatabase()
+ AND query LIKE '%bitShiftLeft%';
diff --git a/tests/queries/0_stateless/03262_udf_in_constraint.reference b/tests/queries/0_stateless/03262_udf_in_constraint.reference
new file mode 100644
index 00000000000..29d403b85a8
--- /dev/null
+++ b/tests/queries/0_stateless/03262_udf_in_constraint.reference
@@ -0,0 +1,2 @@
+CREATE TABLE default.t0\n(\n `c0` Int32,\n CONSTRAINT c1 CHECK c0 > 5\n)\nENGINE = MergeTree\nORDER BY tuple()\nSETTINGS index_granularity = 8192
+10
diff --git a/tests/queries/0_stateless/03262_udf_in_constraint.sh b/tests/queries/0_stateless/03262_udf_in_constraint.sh
new file mode 100755
index 00000000000..3c36e7caeb4
--- /dev/null
+++ b/tests/queries/0_stateless/03262_udf_in_constraint.sh
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+
+CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
+# shellcheck source=../shell_config.sh
+. "$CUR_DIR"/../shell_config.sh
+
+$CLICKHOUSE_CLIENT -q "
+ CREATE FUNCTION ${CLICKHOUSE_DATABASE}_function AS (x) -> x > 5;
+ CREATE TABLE t0 (c0 Int, CONSTRAINT c1 CHECK ${CLICKHOUSE_DATABASE}_function(c0)) ENGINE = MergeTree() ORDER BY tuple();
+ SHOW CREATE TABLE t0;
+ INSERT INTO t0(c0) VALUES (10);
+ INSERT INTO t0(c0) VALUES (3); -- {serverError VIOLATED_CONSTRAINT}
+ SELECT * FROM t0;
+
+ DROP TABLE t0;
+ DROP FUNCTION ${CLICKHOUSE_DATABASE}_function;
+"
diff --git a/tests/queries/0_stateless/03266_with_fill_staleness.reference b/tests/queries/0_stateless/03266_with_fill_staleness.reference
new file mode 100644
index 00000000000..25d7b7c3f24
--- /dev/null
+++ b/tests/queries/0_stateless/03266_with_fill_staleness.reference
@@ -0,0 +1,151 @@
+add samples
+regular with fill
+2016-06-15 23:00:00 0 original
+2016-06-15 23:00:01 0
+2016-06-15 23:00:02 0
+2016-06-15 23:00:03 0
+2016-06-15 23:00:04 0
+2016-06-15 23:00:05 5 original
+2016-06-15 23:00:06 5
+2016-06-15 23:00:07 5
+2016-06-15 23:00:08 5
+2016-06-15 23:00:09 5
+2016-06-15 23:00:10 10 original
+2016-06-15 23:00:11 10
+2016-06-15 23:00:12 10
+2016-06-15 23:00:13 10
+2016-06-15 23:00:14 10
+2016-06-15 23:00:15 15 original
+2016-06-15 23:00:16 15
+2016-06-15 23:00:17 15
+2016-06-15 23:00:18 15
+2016-06-15 23:00:19 15
+2016-06-15 23:00:20 20 original
+2016-06-15 23:00:21 20
+2016-06-15 23:00:22 20
+2016-06-15 23:00:23 20
+2016-06-15 23:00:24 20
+2016-06-15 23:00:25 25 original
+staleness 1 seconds
+2016-06-15 23:00:00 0 original
+2016-06-15 23:00:05 5 original
+2016-06-15 23:00:10 10 original
+2016-06-15 23:00:15 15 original
+2016-06-15 23:00:20 20 original
+2016-06-15 23:00:25 25 original
+staleness 3 seconds
+2016-06-15 23:00:00 0 original
+2016-06-15 23:00:01 0
+2016-06-15 23:00:02 0
+2016-06-15 23:00:05 5 original
+2016-06-15 23:00:06 5
+2016-06-15 23:00:07 5
+2016-06-15 23:00:10 10 original
+2016-06-15 23:00:11 10
+2016-06-15 23:00:12 10
+2016-06-15 23:00:15 15 original
+2016-06-15 23:00:16 15
+2016-06-15 23:00:17 15
+2016-06-15 23:00:20 20 original
+2016-06-15 23:00:21 20
+2016-06-15 23:00:22 20
+2016-06-15 23:00:25 25 original
+2016-06-15 23:00:26 25
+2016-06-15 23:00:27 25
+descending order
+2016-06-15 23:00:25 25 original
+2016-06-15 23:00:24 25
+2016-06-15 23:00:20 20 original
+2016-06-15 23:00:19 20
+2016-06-15 23:00:15 15 original
+2016-06-15 23:00:14 15
+2016-06-15 23:00:10 10 original
+2016-06-15 23:00:09 10
+2016-06-15 23:00:05 5 original
+2016-06-15 23:00:04 5
+2016-06-15 23:00:00 0 original
+2016-06-15 22:59:59 0
+staleness with to and step
+2016-06-15 23:00:00 0 original
+2016-06-15 23:00:03 0
+2016-06-15 23:00:05 5 original
+2016-06-15 23:00:06 5
+2016-06-15 23:00:09 5
+2016-06-15 23:00:10 10 original
+2016-06-15 23:00:12 10
+2016-06-15 23:00:15 15 original
+2016-06-15 23:00:18 15
+2016-06-15 23:00:20 20 original
+2016-06-15 23:00:21 20
+2016-06-15 23:00:24 20
+2016-06-15 23:00:25 25 original
+2016-06-15 23:00:27 25
+2016-06-15 23:00:30 25
+staleness with another regular with fill
+2016-06-15 23:00:00 1970-01-01 01:00:00 0
+2016-06-15 23:00:00 1970-01-01 01:00:01 0
+2016-06-15 23:00:00 1970-01-01 01:00:02 0
+2016-06-15 23:00:00 2016-06-15 23:00:00 0 original
+2016-06-15 23:00:01 1970-01-01 01:00:00 0
+2016-06-15 23:00:01 1970-01-01 01:00:01 0
+2016-06-15 23:00:01 1970-01-01 01:00:02 0
+2016-06-15 23:00:05 1970-01-01 01:00:00 0
+2016-06-15 23:00:05 1970-01-01 01:00:01 0
+2016-06-15 23:00:05 1970-01-01 01:00:02 0
+2016-06-15 23:00:05 2016-06-15 23:00:05 5 original
+2016-06-15 23:00:06 1970-01-01 01:00:00 5
+2016-06-15 23:00:06 1970-01-01 01:00:01 5
+2016-06-15 23:00:06 1970-01-01 01:00:02 5
+2016-06-15 23:00:10 1970-01-01 01:00:00 5
+2016-06-15 23:00:10 1970-01-01 01:00:01 5
+2016-06-15 23:00:10 1970-01-01 01:00:02 5
+2016-06-15 23:00:10 2016-06-15 23:00:10 10 original
+2016-06-15 23:00:11 1970-01-01 01:00:00 10
+2016-06-15 23:00:11 1970-01-01 01:00:01 10
+2016-06-15 23:00:11 1970-01-01 01:00:02 10
+2016-06-15 23:00:15 1970-01-01 01:00:00 10
+2016-06-15 23:00:15 1970-01-01 01:00:01 10
+2016-06-15 23:00:15 1970-01-01 01:00:02 10
+2016-06-15 23:00:15 2016-06-15 23:00:15 15 original
+2016-06-15 23:00:16 1970-01-01 01:00:00 15
+2016-06-15 23:00:16 1970-01-01 01:00:01 15
+2016-06-15 23:00:16 1970-01-01 01:00:02 15
+2016-06-15 23:00:20 1970-01-01 01:00:00 15
+2016-06-15 23:00:20 1970-01-01 01:00:01 15
+2016-06-15 23:00:20 1970-01-01 01:00:02 15
+2016-06-15 23:00:20 2016-06-15 23:00:20 20 original
+2016-06-15 23:00:21 1970-01-01 01:00:00 20
+2016-06-15 23:00:21 1970-01-01 01:00:01 20
+2016-06-15 23:00:21 1970-01-01 01:00:02 20
+2016-06-15 23:00:25 1970-01-01 01:00:00 20
+2016-06-15 23:00:25 1970-01-01 01:00:01 20
+2016-06-15 23:00:25 1970-01-01 01:00:02 20
+2016-06-15 23:00:25 2016-06-15 23:00:25 25 original
+2016-06-15 23:00:26 1970-01-01 01:00:00 25
+2016-06-15 23:00:26 1970-01-01 01:00:01 25
+2016-06-15 23:00:26 1970-01-01 01:00:02 25
+double staleness
+2016-06-15 23:00:00 2016-06-15 23:00:00 0 original
+2016-06-15 23:00:00 2016-06-15 23:00:02 0
+2016-06-15 23:00:00 2016-06-15 23:00:04 0
+2016-06-15 23:00:01 1970-01-01 01:00:00 0
+2016-06-15 23:00:05 2016-06-15 23:00:05 5 original
+2016-06-15 23:00:05 2016-06-15 23:00:07 5
+2016-06-15 23:00:05 2016-06-15 23:00:09 5
+2016-06-15 23:00:06 1970-01-01 01:00:00 5
+2016-06-15 23:00:10 2016-06-15 23:00:10 10 original
+2016-06-15 23:00:10 2016-06-15 23:00:12 10
+2016-06-15 23:00:10 2016-06-15 23:00:14 10
+2016-06-15 23:00:11 1970-01-01 01:00:00 10
+2016-06-15 23:00:15 2016-06-15 23:00:15 15 original
+2016-06-15 23:00:15 2016-06-15 23:00:17 15
+2016-06-15 23:00:15 2016-06-15 23:00:19 15
+2016-06-15 23:00:16 1970-01-01 01:00:00 15
+2016-06-15 23:00:20 2016-06-15 23:00:20 20 original
+2016-06-15 23:00:20 2016-06-15 23:00:22 20
+2016-06-15 23:00:20 2016-06-15 23:00:24 20
+2016-06-15 23:00:21 1970-01-01 01:00:00 20
+2016-06-15 23:00:25 2016-06-15 23:00:25 25 original
+2016-06-15 23:00:25 2016-06-15 23:00:27 25
+2016-06-15 23:00:25 2016-06-15 23:00:29 25
+2016-06-15 23:00:26 1970-01-01 01:00:00 25
diff --git a/tests/queries/0_stateless/03266_with_fill_staleness.sql b/tests/queries/0_stateless/03266_with_fill_staleness.sql
new file mode 100644
index 00000000000..de47d8287ad
--- /dev/null
+++ b/tests/queries/0_stateless/03266_with_fill_staleness.sql
@@ -0,0 +1,34 @@
+SET session_timezone='Europe/Amsterdam';
+SET enable_analyzer=1;
+
+DROP TABLE IF EXISTS with_fill_staleness;
+CREATE TABLE with_fill_staleness (a DateTime, b DateTime, c UInt64) ENGINE = MergeTree ORDER BY a;
+
+SELECT 'add samples';
+
+INSERT INTO with_fill_staleness
+SELECT
+ toDateTime('2016-06-15 23:00:00') + number AS a, a as b, number as c
+FROM numbers(30)
+WHERE (number % 5) == 0;
+
+SELECT 'regular with fill';
+SELECT a, c, 'original' as original FROM with_fill_staleness ORDER BY a ASC WITH FILL INTERPOLATE (c);
+
+SELECT 'staleness 1 seconds';
+SELECT a, c, 'original' as original FROM with_fill_staleness ORDER BY a ASC WITH FILL STALENESS INTERVAL 1 SECOND INTERPOLATE (c);
+
+SELECT 'staleness 3 seconds';
+SELECT a, c, 'original' as original FROM with_fill_staleness ORDER BY a ASC WITH FILL STALENESS INTERVAL 3 SECOND INTERPOLATE (c);
+
+SELECT 'descending order';
+SELECT a, c, 'original' as original FROM with_fill_staleness ORDER BY a DESC WITH FILL STALENESS INTERVAL -2 SECOND INTERPOLATE (c);
+
+SELECT 'staleness with to and step';
+SELECT a, c, 'original' as original FROM with_fill_staleness ORDER BY a ASC WITH FILL TO toDateTime('2016-06-15 23:00:40') STEP 3 STALENESS INTERVAL 7 SECOND INTERPOLATE (c);
+
+SELECT 'staleness with another regular with fill';
+SELECT a, b, c, 'original' as original FROM with_fill_staleness ORDER BY a ASC WITH FILL STALENESS INTERVAL 2 SECOND, b ASC WITH FILL FROM 0 TO 3 INTERPOLATE (c);
+
+SELECT 'double staleness';
+SELECT a, b, c, 'original' as original FROM with_fill_staleness ORDER BY a ASC WITH FILL STALENESS INTERVAL 2 SECOND, b ASC WITH FILL TO toDateTime('2016-06-15 23:01:00') STEP 2 STALENESS 5 INTERPOLATE (c);
diff --git a/tests/queries/0_stateless/03266_with_fill_staleness_cases.reference b/tests/queries/0_stateless/03266_with_fill_staleness_cases.reference
new file mode 100644
index 00000000000..bf8e5bbe331
--- /dev/null
+++ b/tests/queries/0_stateless/03266_with_fill_staleness_cases.reference
@@ -0,0 +1,67 @@
+test-1
+0 5 10 original
+0 5 13
+0 5 16
+0 5 19
+0 5 22
+0 7 0
+7 8 15 original
+7 8 18
+7 8 21
+7 8 24
+7 10 0
+14 10 20 original
+14 10 23
+14 12 0
+test-2-1
+1 0 original
+1 1
+1 2
+1 3
+1 4 original
+1 5
+1 6
+1 7
+1 8 original
+1 9
+1 10
+1 11
+1 12 original
+test-2-2
+1 0 original
+1 1
+1 2
+1 3
+1 4 original
+1 5
+1 6
+1 7
+1 8 original
+1 9
+1 10
+1 11
+1 12 original
+1 13
+1 14
+2 0
+3 0
+4 0
+test-3-1
+25 -10
+25 -8
+25 -6
+25 -4
+25 -2
+25 0
+25 2
+25 4
+25 6
+25 8
+25 10
+25 12
+25 14
+25 16
+25 17 original
+28 -10
+30 18 original
+31 -10
diff --git a/tests/queries/0_stateless/03266_with_fill_staleness_cases.sql b/tests/queries/0_stateless/03266_with_fill_staleness_cases.sql
new file mode 100644
index 00000000000..9e28041c9a1
--- /dev/null
+++ b/tests/queries/0_stateless/03266_with_fill_staleness_cases.sql
@@ -0,0 +1,25 @@
+SET enable_analyzer=1;
+
+DROP TABLE IF EXISTS test;
+CREATE TABLE test (a Int64, b Int64, c Int64) Engine=MergeTree ORDER BY a;
+INSERT INTO test(a, b, c) VALUES (0, 5, 10), (7, 8, 15), (14, 10, 20);
+
+SELECT 'test-1';
+SELECT *, 'original' AS orig FROM test ORDER BY a, b WITH FILL TO 20 STEP 2 STALENESS 3, c WITH FILL TO 25 step 3;
+
+DROP TABLE IF EXISTS test2;
+CREATE TABLE test2 (a Int64, b Int64) Engine=MergeTree ORDER BY a;
+INSERT INTO test2(a, b) values (1, 0), (1, 4), (1, 8), (1, 12);
+
+SELECT 'test-2-1';
+SELECT *, 'original' AS orig FROM test2 ORDER BY a, b WITH FILL;
+
+SELECT 'test-2-2';
+SELECT *, 'original' AS orig FROM test2 ORDER BY a WITH FILL to 20 STALENESS 4, b WITH FILL TO 15 STALENESS 7;
+
+DROP TABLE IF EXISTS test2;
+CREATE TABLE test3 (a Int64, b Int64) Engine=MergeTree ORDER BY a;
+INSERT INTO test3(a, b) VALUES (25, 17), (30, 18);
+
+SELECT 'test-3-1';
+SELECT a, b, 'original' AS orig FROM test3 ORDER BY a WITH FILL TO 33 STEP 3, b WITH FILL FROM -10 STEP 2;
diff --git a/tests/queries/0_stateless/03266_with_fill_staleness_errors.reference b/tests/queries/0_stateless/03266_with_fill_staleness_errors.reference
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/queries/0_stateless/03266_with_fill_staleness_errors.sql b/tests/queries/0_stateless/03266_with_fill_staleness_errors.sql
new file mode 100644
index 00000000000..fbfaf3743ca
--- /dev/null
+++ b/tests/queries/0_stateless/03266_with_fill_staleness_errors.sql
@@ -0,0 +1,5 @@
+SET enable_analyzer=1;
+
+SELECT 1 AS a, 2 AS b ORDER BY a, b WITH FILL FROM 0 TO 10 STALENESS 3; -- { serverError INVALID_WITH_FILL_EXPRESSION }
+SELECT 1 AS a, 2 AS b ORDER BY a, b DESC WITH FILL TO 10 STALENESS 3; -- { serverError INVALID_WITH_FILL_EXPRESSION }
+SELECT 1 AS a, 2 AS b ORDER BY a, b ASC WITH FILL TO 10 STALENESS -3; -- { serverError INVALID_WITH_FILL_EXPRESSION }