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

Function bindFunc

src/function/table/stats_info.cpp:54–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54static 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
82function_set StatsInfoFunction::getFunctionSet() {
83 function_set functionSet;

Callers

nothing calls this directly

Calls 8

containsTableMethod · 0.80
getTableCatalogEntryMethod · 0.80
createVariablesMethod · 0.80
getTableTypeMethod · 0.45
push_backMethod · 0.45
getPropertiesMethod · 0.45
getNameMethod · 0.45
getTableMethod · 0.45

Tested by

no test coverage detected