Fix for analyzer

This commit is contained in:
avogar 2023-09-14 20:10:07 +00:00
parent 93c49dfeaa
commit b9c28ef1f7
4 changed files with 4 additions and 8 deletions

View File

@ -6247,7 +6247,7 @@ void QueryAnalyzer::resolveTableFunction(QueryTreeNodePtr & table_function_node,
.getTable(insertion_table, scope_context)
->getInMemoryMetadataPtr()
->getColumns();
const auto & insert_column_names = insert_columns.getInsertable().getNames();
const auto & insert_column_names = scope_context->hasInsertionTableColumnNames() ? *scope_context->getInsertionTableColumnNames() : insert_columns.getInsertable().getNames();
DB::ColumnsDescription structure_hint;
bool use_columns_from_insert_query = true;

View File

@ -1592,7 +1592,7 @@ StoragePtr Context::executeTableFunction(const ASTPtr & table_expression, const
->getInMemoryMetadataPtr()
->getColumns();
const auto & insert_column_names = hasInsertionTableColumnNames() ? getInsertionTableColumnNames() : insert_columns.getInsertable().getNames();
const auto & insert_column_names = hasInsertionTableColumnNames() ? *getInsertionTableColumnNames() : insert_columns.getInsertable().getNames();
DB::ColumnsDescription structure_hint;
bool use_columns_from_insert_query = true;

View File

@ -723,11 +723,7 @@ public:
bool hasInsertionTableColumnNames() const { return insertion_table_info.column_names.has_value(); }
void setInsertionTable(StorageID db_and_table, const std::optional<Names> & column_names = std::nullopt) { insertion_table_info = {std::move(db_and_table), column_names}; }
const StorageID & getInsertionTable() const { return insertion_table_info.table; }
const Names & getInsertionTableColumnNames() const
{
assert(insertion_table_info.column_names.has_value());
return *insertion_table_info.column_names;
}
const std::optional<Names> & getInsertionTableColumnNames() const{ return insertion_table_info.column_names; }
void setDistributed(bool is_distributed_) { is_distributed = is_distributed_; }
bool isDistributed() const { return is_distributed; }

View File

@ -474,7 +474,7 @@ BlockIO InterpreterInsertQuery::execute()
auto new_context = Context::createCopy(context);
new_context->setSettings(new_settings);
new_context->setInsertionTable(getContext()->getInsertionTable());
new_context->setInsertionTable(getContext()->getInsertionTable(), getContext()->getInsertionTableColumnNames());
auto select_query_options = SelectQueryOptions(QueryProcessingStage::Complete, 1);