Fix more tests.

This commit is contained in:
Nikolai Kochetov 2023-05-30 18:51:18 +00:00
parent 8cec00dd6e
commit c740328426
3 changed files with 20 additions and 6 deletions

View File

@ -1420,6 +1420,8 @@ FutureSetPtr ActionsMatcher::makeSet(const ASTFunction & node, Data & data, bool
return data.prepared_sets->addFromStorage(set_key, storage_set->getSet()); return data.prepared_sets->addFromStorage(set_key, storage_set->getSet());
} }
if (!data.getContext()->isGlobalContext())
{
// std::cerr << ".... checking for " << identifier->getColumnName() << std::endl; // std::cerr << ".... checking for " << identifier->getColumnName() << std::endl;
if (auto tmp_table = data.getContext()->findExternalTable(identifier->getColumnName())) if (auto tmp_table = data.getContext()->findExternalTable(identifier->getColumnName()))
{ {
@ -1427,6 +1429,7 @@ FutureSetPtr ActionsMatcher::makeSet(const ASTFunction & node, Data & data, bool
// std::cerr << "Found " << reinterpret_cast<const void *>(tmp_table.get()) << " " << reinterpret_cast<const void *>(external_table_set.get()) << std::endl; // std::cerr << "Found " << reinterpret_cast<const void *>(tmp_table.get()) << " " << reinterpret_cast<const void *>(external_table_set.get()) << std::endl;
} }
} }
}
/// We get the stream of blocks for the subquery. Create Set and put it in place of the subquery. /// We get the stream of blocks for the subquery. Create Set and put it in place of the subquery.
// String set_id = right_in_operand->getColumnName(); // String set_id = right_in_operand->getColumnName();

View File

@ -90,6 +90,8 @@ public:
in_second_argument_node_type == QueryTreeNodeType::UNION) in_second_argument_node_type == QueryTreeNodeType::UNION)
{ {
auto set_key = PreparedSetKey::forSubquery(in_second_argument->getTreeHash()); auto set_key = PreparedSetKey::forSubquery(in_second_argument->getTreeHash());
if (sets.getFuture(set_key))
return;
auto subquery_options = select_query_options.subquery(); auto subquery_options = select_query_options.subquery();
Planner subquery_planner( Planner subquery_planner(

View File

@ -1236,6 +1236,15 @@ static void buildIndexes(
if (!indexes->use_skip_indexes) if (!indexes->use_skip_indexes)
return; return;
const SelectQueryInfo * info = &query_info;
std::optional<SelectQueryInfo> info_copy;
if (settings.allow_experimental_analyzer)
{
info_copy.emplace(query_info);
info_copy->filter_actions_dag = filter_actions_dag;
info = &*info_copy;
}
UsefulSkipIndexes skip_indexes; UsefulSkipIndexes skip_indexes;
using Key = std::pair<String, size_t>; using Key = std::pair<String, size_t>;
std::map<Key, size_t> merged; std::map<Key, size_t> merged;
@ -1249,14 +1258,14 @@ static void buildIndexes(
if (inserted) if (inserted)
{ {
skip_indexes.merged_indices.emplace_back(); skip_indexes.merged_indices.emplace_back();
skip_indexes.merged_indices.back().condition = index_helper->createIndexMergedCondition(query_info, metadata_snapshot); skip_indexes.merged_indices.back().condition = index_helper->createIndexMergedCondition(*info, metadata_snapshot);
} }
skip_indexes.merged_indices[it->second].addIndex(index_helper); skip_indexes.merged_indices[it->second].addIndex(index_helper);
} }
else else
{ {
auto condition = index_helper->createIndexCondition(query_info, context); auto condition = index_helper->createIndexCondition(*info, context);
if (!condition->alwaysUnknownOrTrue()) if (!condition->alwaysUnknownOrTrue())
skip_indexes.useful_indices.emplace_back(index_helper, condition); skip_indexes.useful_indices.emplace_back(index_helper, condition);
} }