| 157 | } |
| 158 | |
| 159 | static std::unique_ptr<TableFuncBindData> bindFunc(const main::ClientContext* context, |
| 160 | const TableFuncBindInput* input) { |
| 161 | std::vector<std::string> columnNames; |
| 162 | std::vector<LogicalType> columnTypes; |
| 163 | columnNames.emplace_back("property id"); |
| 164 | columnTypes.push_back(LogicalType::INT32()); |
| 165 | columnNames.emplace_back("name"); |
| 166 | columnTypes.push_back(LogicalType::STRING()); |
| 167 | columnNames.emplace_back("type"); |
| 168 | columnTypes.push_back(LogicalType::STRING()); |
| 169 | columnNames.emplace_back("default expression"); |
| 170 | columnTypes.push_back(LogicalType::STRING()); |
| 171 | auto name = common::StringUtils::split(input->getLiteralVal<std::string>(0), "."); |
| 172 | |
| 173 | std::vector<PropertyInfo> infos; |
| 174 | CatalogEntryType type = CatalogEntryType::DUMMY_ENTRY; |
| 175 | auto transaction = transaction::Transaction::Get(*context); |
| 176 | if (name.size() == 1) { |
| 177 | auto tableName = name[0]; |
| 178 | auto catalog = Catalog::Get(*context); |
| 179 | if (catalog->containsTable(transaction, tableName)) { |
| 180 | auto entry = catalog->getTableCatalogEntry(transaction, tableName); |
| 181 | switch (entry->getType()) { |
| 182 | case CatalogEntryType::NODE_TABLE_ENTRY: { |
| 183 | columnNames.emplace_back("primary key"); |
| 184 | columnTypes.push_back(LogicalType::BOOL()); |
| 185 | infos = getNodePropertyInfos(entry->ptrCast<NodeTableCatalogEntry>()); |
| 186 | type = CatalogEntryType::NODE_TABLE_ENTRY; |
| 187 | } break; |
| 188 | case CatalogEntryType::REL_GROUP_ENTRY: { |
| 189 | columnNames.emplace_back("storage_direction"); |
| 190 | columnTypes.push_back(LogicalType::STRING()); |
| 191 | infos = getRelPropertyInfos(entry->ptrCast<RelGroupCatalogEntry>()); |
| 192 | type = CatalogEntryType::REL_GROUP_ENTRY; |
| 193 | } break; |
| 194 | default: |
| 195 | UNREACHABLE_CODE; |
| 196 | } |
| 197 | } else { |
| 198 | throw CatalogException(std::format("{} does not exist in catalog.", tableName)); |
| 199 | } |
| 200 | } else { |
| 201 | auto dbName = name[0]; |
| 202 | auto tableName = name[1]; |
| 203 | auto db = main::DatabaseManager::Get(*context)->getAttachedDatabase(dbName); |
| 204 | auto entry = db->getCatalog()->getTableCatalogEntry(transaction, tableName); |
| 205 | infos = getForeignPropertyInfos(entry); |
| 206 | type = CatalogEntryType::FOREIGN_TABLE_ENTRY; |
| 207 | } |
| 208 | columnNames = TableFunction::extractYieldVariables(columnNames, input->yieldVariables); |
| 209 | auto columns = input->binder->createVariables(columnNames, columnTypes); |
| 210 | return std::make_unique<TableInfoBindData>(type, std::move(infos), columns); |
| 211 | } |
| 212 | |
| 213 | function_set TableInfoFunction::getFunctionSet() { |
| 214 | function_set functionSet; |
nothing calls this directly
no test coverage detected