| 52 | } |
| 53 | |
| 54 | static std::unique_ptr<TableFuncBindData> bindFunc(const ClientContext* context, |
| 55 | const TableFuncBindInput* input) { |
| 56 | const auto tableName = input->getLiteralVal<std::string>(0); |
| 57 | const auto catalog = Catalog::Get(*context); |
| 58 | if (!catalog->containsTable(transaction::Transaction::Get(*context), tableName)) { |
| 59 | throw BinderException{"Table " + tableName + " does not exist!"}; |
| 60 | } |
| 61 | auto tableEntry = |
| 62 | catalog->getTableCatalogEntry(transaction::Transaction::Get(*context), tableName); |
| 63 | if (tableEntry->getTableType() != TableType::NODE) { |
| 64 | throw BinderException{ |
| 65 | "Stats from a non-node table " + tableName + " is not supported yet!"}; |
| 66 | } |
| 67 | |
| 68 | std::vector<std::string> columnNames = {"cardinality"}; |
| 69 | std::vector<LogicalType> columnTypes; |
| 70 | columnTypes.push_back(LogicalType::INT64()); |
| 71 | for (auto& propDef : tableEntry->getProperties()) { |
| 72 | columnNames.push_back(propDef.getName() + "_distinct_count"); |
| 73 | columnTypes.push_back(LogicalType::INT64()); |
| 74 | } |
| 75 | const auto storageManager = storage::StorageManager::Get(*context); |
| 76 | auto table = storageManager->getTable(tableEntry->getTableID()); |
| 77 | columnNames = TableFunction::extractYieldVariables(columnNames, input->yieldVariables); |
| 78 | auto columns = input->binder->createVariables(columnNames, columnTypes); |
| 79 | return std::make_unique<StatsInfoBindData>(columns, tableEntry, table, context); |
| 80 | } |
| 81 | |
| 82 | function_set StatsInfoFunction::getFunctionSet() { |
| 83 | function_set functionSet; |
nothing calls this directly
no test coverage detected