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

Method bindFunc

src/function/struct/struct_extract_function.cpp:14–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12namespace function {
13
14std::unique_ptr<FunctionBindData> StructExtractFunctions::bindFunc(
15 const ScalarBindFuncInput& input) {
16 const auto& structType = input.arguments[0]->getDataType();
17 if (input.arguments[1]->expressionType != ExpressionType::LITERAL) {
18 throw BinderException("Key name for struct/union extract must be STRING literal.");
19 }
20 auto key =
21 input.arguments[1]->constPtrCast<LiteralExpression>()->getValue().getValue<std::string>();
22 auto fieldIdx = StructType::getFieldIdx(structType, key);
23 if (fieldIdx == INVALID_STRUCT_FIELD_IDX) {
24 throw BinderException(std::format("Invalid struct field name: {}.", key));
25 }
26 auto paramTypes = ExpressionUtil::getDataTypes(input.arguments);
27 auto resultType = StructType::getField(structType, fieldIdx).getType().copy();
28 auto bindData = std::make_unique<StructExtractBindData>(std::move(resultType), fieldIdx);
29 bindData->paramTypes.push_back(input.arguments[0]->getDataType().copy());
30 bindData->paramTypes.push_back(LogicalType(input.definition->parameterTypeIDs[1]));
31 return bindData;
32}
33
34void StructExtractFunctions::compileFunc(FunctionBindData* bindData,
35 const std::vector<std::shared_ptr<ValueVector>>& parameters,

Callers

nothing calls this directly

Calls 6

getDataTypeMethod · 0.80
LogicalTypeClass · 0.50
getValueMethod · 0.45
copyMethod · 0.45
getTypeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected