diff --git a/src/function/table/table_info.cpp b/src/function/table/table_info.cpp index 2f8004c2f..7e1ca28eb 100644 --- a/src/function/table/table_info.cpp +++ b/src/function/table/table_info.cpp @@ -168,42 +168,42 @@ static std::unique_ptr bindFunc(const main::ClientContext* co columnTypes.push_back(LogicalType::STRING()); columnNames.emplace_back("default expression"); columnTypes.push_back(LogicalType::STRING()); - auto name = common::StringUtils::split(input->getLiteralVal(0), "."); + auto tableName = input->getLiteralVal(0); std::vector infos; CatalogEntryType type = CatalogEntryType::DUMMY_ENTRY; auto transaction = transaction::Transaction::Get(*context); - if (name.size() == 1) { - auto tableName = name[0]; - auto catalog = Catalog::Get(*context); - if (catalog->containsTable(transaction, tableName)) { - auto entry = catalog->getTableCatalogEntry(transaction, tableName); - switch (entry->getType()) { - case CatalogEntryType::NODE_TABLE_ENTRY: { - columnNames.emplace_back("primary key"); - columnTypes.push_back(LogicalType::BOOL()); - infos = getNodePropertyInfos(entry->ptrCast()); - type = CatalogEntryType::NODE_TABLE_ENTRY; - } break; - case CatalogEntryType::REL_GROUP_ENTRY: { - columnNames.emplace_back("storage_direction"); - columnTypes.push_back(LogicalType::STRING()); - infos = getRelPropertyInfos(entry->ptrCast()); - type = CatalogEntryType::REL_GROUP_ENTRY; - } break; - default: - UNREACHABLE_CODE; - } + auto catalog = Catalog::Get(*context); + if (catalog->containsTable(transaction, tableName)) { + auto entry = catalog->getTableCatalogEntry(transaction, tableName); + switch (entry->getType()) { + case CatalogEntryType::NODE_TABLE_ENTRY: { + columnNames.emplace_back("primary key"); + columnTypes.push_back(LogicalType::BOOL()); + infos = getNodePropertyInfos(entry->ptrCast()); + type = CatalogEntryType::NODE_TABLE_ENTRY; + } break; + case CatalogEntryType::REL_GROUP_ENTRY: { + columnNames.emplace_back("storage_direction"); + columnTypes.push_back(LogicalType::STRING()); + infos = getRelPropertyInfos(entry->ptrCast()); + type = CatalogEntryType::REL_GROUP_ENTRY; + } break; + default: + UNREACHABLE_CODE; + } + } else { + auto splitName = common::StringUtils::split(tableName, "."); + if (splitName.size() >= 2) { + auto dbName = splitName[0]; + auto tblName = splitName[1]; + auto db = main::DatabaseManager::Get(*context)->getAttachedDatabase(dbName); + auto entry = db->getCatalog()->getTableCatalogEntry(transaction, tblName); + infos = getForeignPropertyInfos(entry); + type = CatalogEntryType::FOREIGN_TABLE_ENTRY; } else { throw CatalogException(std::format("{} does not exist in catalog.", tableName)); } - } else { - auto dbName = name[0]; - auto tableName = name[1]; - auto db = main::DatabaseManager::Get(*context)->getAttachedDatabase(dbName); - auto entry = db->getCatalog()->getTableCatalogEntry(transaction, tableName); - infos = getForeignPropertyInfos(entry); - type = CatalogEntryType::FOREIGN_TABLE_ENTRY; } columnNames = TableFunction::extractYieldVariables(columnNames, input->yieldVariables); auto columns = input->binder->createVariables(columnNames, columnTypes); diff --git a/test/test_files/issue/issue9.test b/test/test_files/issue/issue9.test new file mode 100644 index 000000000..be95a8b01 --- /dev/null +++ b/test/test_files/issue/issue9.test @@ -0,0 +1,14 @@ +-DATASET CSV empty +-BUFFER_POOL_SIZE 1024000000 + +-- + +-CASE issue9 +-STATEMENT CREATE NODE TABLE `a.b`(id STRING, PRIMARY KEY(id)); +---- ok +-STATEMENT CALL show_tables() RETURN name, type; +---- 1 +a.b|NODE +-STATEMENT CALL table_info('a.b') RETURN *; +---- 1 +0|id|STRING|NULL|True