diff --git a/src/Analyzer/Passes/QueryAnalysisPass.cpp b/src/Analyzer/Passes/QueryAnalysisPass.cpp index 0dc3026afc0..b235918c438 100644 --- a/src/Analyzer/Passes/QueryAnalysisPass.cpp +++ b/src/Analyzer/Passes/QueryAnalysisPass.cpp @@ -6400,23 +6400,27 @@ void QueryAnalyzer::resolveTableFunction(QueryTreeNodePtr & table_function_node, { String database_name = scope.context->getCurrentDatabase(); - String table_name = table_function_node->getOriginalAST()->as()->name; + String table_name = ""; - if (table_function_node->getOriginalAST()->as()->is_compound_name) + if (table_function_node->getOriginalAST() && table_function_node->getOriginalAST()->as()) { - std::vector parts; - splitInto<'.'>(parts, table_function_node->getOriginalAST()->as()->name); - - if (parts.size() == 2) + table_name = table_function_node->getOriginalAST()->as()->name; + if (table_function_node->getOriginalAST()->as()->is_compound_name) { - database_name = parts[0]; - table_name = parts[1]; + std::vector parts; + splitInto<'.'>(parts, table_function_node->getOriginalAST()->as()->name); + + if (parts.size() == 2) + { + database_name = parts[0]; + table_name = parts[1]; + } } } auto & table_function_node_typed = table_function_node->as(); - StoragePtr table = DatabaseCatalog::instance().tryGetTable({database_name, table_name}, scope.context->getQueryContext()); + StoragePtr table = table_name.empty() ? nullptr : DatabaseCatalog::instance().tryGetTable({database_name, table_name}, scope.context->getQueryContext()); if (table) { if (table.get()->isView() && table->as() && table->as()->isParameterizedView())