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

Function bindFunc

src/function/path/properties_function.cpp:14–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12namespace function {
13
14static std::unique_ptr<FunctionBindData> bindFunc(const ScalarBindFuncInput& input) {
15 if (input.arguments[1]->expressionType != ExpressionType::LITERAL) {
16 throw BinderException(std::format("Expected literal input as the second argument for {}().",
17 PropertiesFunction::name));
18 }
19 auto literalExpr = input.arguments[1]->constPtrCast<LiteralExpression>();
20 auto key = literalExpr->getValue().getValue<std::string>();
21 const auto& listType = input.arguments[0]->getDataType();
22 const auto& childType = ListType::getChildType(listType);
23 struct_field_idx_t fieldIdx = 0;
24 if (childType.getLogicalTypeID() == LogicalTypeID::NODE ||
25 childType.getLogicalTypeID() == LogicalTypeID::REL) {
26 fieldIdx = StructType::getFieldIdx(childType, key);
27 if (fieldIdx == INVALID_STRUCT_FIELD_IDX) {
28 throw BinderException(std::format("Invalid property name: {}.", key));
29 }
30 } else {
31 throw BinderException(
32 std::format("Cannot extract properties from {}.", listType.toString()));
33 }
34 const auto& field = StructType::getField(childType, fieldIdx);
35 auto returnType = LogicalType::LIST(field.getType().copy());
36 auto bindData = std::make_unique<PropertiesBindData>(std::move(returnType), fieldIdx);
37 bindData->paramTypes.push_back(input.arguments[0]->getDataType().copy());
38 bindData->paramTypes.push_back(LogicalType(input.definition->parameterTypeIDs[1]));
39 return bindData;
40}
41
42static void compileFunc(FunctionBindData* bindData,
43 const std::vector<std::shared_ptr<ValueVector>>& parameters,

Callers

nothing calls this directly

Calls 9

getChildTypeFunction · 0.85
getDataTypeMethod · 0.80
getLogicalTypeIDMethod · 0.80
LogicalTypeClass · 0.50
getValueMethod · 0.45
toStringMethod · 0.45
copyMethod · 0.45
getTypeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected