MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / bindNodeTableEntry

Method bindNodeTableEntry

src/binder/bind/bind_graph_pattern.cpp:696–745  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

694}
695
696std::pair<TableCatalogEntry*, std::string> Binder::bindNodeTableEntry(
697 const std::string& name) const {
698 auto transaction = transaction::Transaction::Get(*clientContext);
699 auto useInternal = clientContext->useInternalCatalogEntry();
700
701 std::string dbName;
702 std::string tableName = name;
703 auto dotPos = name.find('.');
704 if (dotPos != std::string::npos) {
705 dbName = name.substr(0, dotPos);
706 tableName = name.substr(dotPos + 1);
707 }
708
709 if (!dbName.empty()) {
710 // Qualified name: db.table
711 auto attachedDB = main::DatabaseManager::Get(*clientContext)->getAttachedDatabase(dbName);
712 if (!attachedDB) {
713 throw BinderException(std::format("Attached database {} does not exist.", dbName));
714 }
715 auto attachedCatalog = attachedDB->getCatalog();
716 if (!attachedCatalog->containsTable(transaction, tableName, useInternal)) {
717 throw BinderException(
718 std::format("Table {} does not exist in attached database {}.", tableName, dbName));
719 }
720 return {attachedCatalog->getTableCatalogEntry(transaction, tableName, useInternal), dbName};
721 } else {
722 // Check if there's a default graph set and use its catalog
723 auto dbManager = main::DatabaseManager::Get(*clientContext);
724 catalog::Catalog* catalog = nullptr;
725 auto defaultGraphCatalog = dbManager->getDefaultGraphCatalog();
726 if (defaultGraphCatalog != nullptr) {
727 catalog = defaultGraphCatalog;
728 } else {
729 catalog = Catalog::Get(*clientContext);
730 }
731 // Unqualified name: only search main catalog
732 // Foreign tables require qualified names (db.table) to avoid ambiguity
733 bool hasTable = catalog->containsTable(transaction, name, useInternal);
734 if (hasTable) {
735 return {catalog->getTableCatalogEntry(transaction, name, useInternal), ""};
736 }
737 // Check if this is an ANY graph (has _nodes table)
738 // In ANY graphs, labels are stored dynamically in the _nodes table
739 bool hasNodes = catalog->containsTable(transaction, "_nodes", useInternal);
740 if (hasNodes) {
741 return {catalog->getTableCatalogEntry(transaction, "_nodes", useInternal), ""};
742 }
743 throw BinderException(std::format("Table {} does not exist.", name));
744 }
745}
746
747std::vector<TableCatalogEntry*> Binder::bindRelGroupEntries(
748 const std::vector<std::string>& tableNames) const {

Callers

nothing calls this directly

Calls 7

getCatalogMethod · 0.80
containsTableMethod · 0.80
getTableCatalogEntryMethod · 0.80
findMethod · 0.45
emptyMethod · 0.45
getAttachedDatabaseMethod · 0.45

Tested by

no test coverage detected