Fix arguments parsing for object storage functions

This commit is contained in:
Konstantin Bogdanov 2024-11-18 18:56:02 +01:00
parent 03352372e9
commit 3ff22e3fc1
No known key found for this signature in database
5 changed files with 14 additions and 25 deletions

View File

@ -86,7 +86,9 @@ void StorageObjectStorageCluster::updateQueryToSendIfNeeded(
const DB::StorageSnapshotPtr & storage_snapshot,
const ContextPtr & context)
{
ASTExpressionList * expression_list = extractTableFunctionArgumentsFromSelectQuery(query);
auto * table_function = extractTableFunctionFromSelectQuery(query);
auto * expression_list = table_function->arguments->as<ASTExpressionList>();
if (!expression_list)
{
throw Exception(
@ -105,10 +107,16 @@ void StorageObjectStorageCluster::updateQueryToSendIfNeeded(
configuration->getEngineName());
}
ASTPtr cluster_name_arg = args.front();
args.erase(args.begin());
configuration->addStructureAndFormatToArgsIfNeeded(args, structure, configuration->format, context);
args.insert(args.begin(), cluster_name_arg);
if (table_function->name == configuration->getTypeName())
configuration->addStructureAndFormatToArgsIfNeeded(args, structure, configuration->format, context);
else
{
ASTPtr cluster_name_arg = args.front();
args.erase(args.begin());
configuration->addStructureAndFormatToArgsIfNeeded(args, structure, configuration->format, context);
args.insert(args.begin(), cluster_name_arg);
}
}
RemoteQueryExecutor::Extension StorageObjectStorageCluster::getTaskIteratorExtension(

View File

@ -10,21 +10,6 @@
namespace DB
{
ASTExpressionList * extractTableFunctionArgumentsFromSelectQuery(ASTPtr & query)
{
auto * select_query = query->as<ASTSelectQuery>();
if (!select_query || !select_query->tables())
return nullptr;
auto * tables = select_query->tables()->as<ASTTablesInSelectQuery>();
auto * table_expression = tables->children[0]->as<ASTTablesInSelectQueryElement>()->table_expression->as<ASTTableExpression>();
if (!table_expression->table_function)
return nullptr;
auto * table_function = table_expression->table_function->as<ASTFunction>();
return table_function->arguments->as<ASTExpressionList>();
}
ASTFunction * extractTableFunctionFromSelectQuery(ASTPtr & query)
{
auto * select_query = query->as<ASTSelectQuery>();

View File

@ -35,7 +35,7 @@ public:
if (args.empty())
throw Exception(ErrorCodes::LOGICAL_ERROR, "Unexpected empty list of arguments for {}Cluster table function", Base::name);
if (table_function-> name == Base::name)
if (table_function->name == Base::name)
Base::updateStructureAndFormatArgumentsIfNeeded(args, structure_, format_, context);
else
{

View File

@ -151,8 +151,6 @@ StoragePtr TableFunctionObjectStorage<Definition, Configuration>::executeImpl(
&& !parallel_replicas_cluster_name.empty()
&& !context->isDistributed();
LOG_DEBUG(&Poco::Logger::get("TableFunctionObjectStorage"), "Is distributed: {}", context->isDistributed());
if (can_use_parallel_replicas)
{
storage = std::make_shared<StorageObjectStorageCluster>(

View File

@ -159,8 +159,6 @@ StoragePtr TableFunctionURL::getStorage(
&& !parallel_replicas_cluster_name.empty()
&& !global_context->isDistributed();
LOG_DEBUG(&Poco::Logger::get("TableFunctionURL"), "Is distributed: {}", global_context->isDistributed());
if (can_use_parallel_replicas)
{
return std::make_shared<StorageURLCluster>(