Always add table name while converting ColumnNode to AST

This commit is contained in:
Dmitry Novik 2023-06-01 15:21:55 +00:00
parent 99b35eca07
commit 480db8622d

View File

@ -108,8 +108,7 @@ ASTPtr ColumnNode::toASTImpl(const ConvertToASTOptions & options) const
{
column_identifier_parts = {column_source->getAlias()};
}
else if (auto * table_node = column_source->as<TableNode>();
table_node && options.fully_qualified_identifiers)
else if (auto * table_node = column_source->as<TableNode>())
{
if (!table_node->getTemporaryTableName().empty())
{
@ -118,7 +117,7 @@ ASTPtr ColumnNode::toASTImpl(const ConvertToASTOptions & options) const
else
{
const auto & table_storage_id = table_node->getStorageID();
if (table_storage_id.hasDatabase())
if (table_storage_id.hasDatabase() && options.fully_qualified_identifiers)
column_identifier_parts = { table_storage_id.getDatabaseName(), table_storage_id.getTableName() };
else
column_identifier_parts = { table_storage_id.getTableName() };