Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions src/function/table/table_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,42 +168,42 @@ static std::unique_ptr<TableFuncBindData> 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<std::string>(0), ".");
auto tableName = input->getLiteralVal<std::string>(0);

std::vector<PropertyInfo> 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<NodeTableCatalogEntry>());
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<RelGroupCatalogEntry>());
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<NodeTableCatalogEntry>());
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<RelGroupCatalogEntry>());
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);
Expand Down
14 changes: 14 additions & 0 deletions test/test_files/issue/issue9.test
Original file line number Diff line number Diff line change
@@ -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
Loading