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

Function bindFunc

src/function/struct/struct_pack_function.cpp:11–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9namespace function {
10
11static std::unique_ptr<FunctionBindData> bindFunc(const ScalarBindFuncInput& input) {
12 std::vector<StructField> fields;
13 if (input.arguments.size() > INVALID_STRUCT_FIELD_IDX - 1) {
14 throw BinderException(std::format("Too many fields in STRUCT literal (max {}, got {})",
15 INVALID_STRUCT_FIELD_IDX - 1, input.arguments.size()));
16 }
17 std::unordered_set<std::string> fieldNameSet;
18 for (auto i = 0u; i < input.arguments.size(); i++) {
19 auto& argument = input.arguments[i];
20 if (argument->getDataType().getLogicalTypeID() == LogicalTypeID::ANY) {
21 argument->cast(LogicalType::STRING());
22 }
23 if (i >= input.optionalArguments.size()) {
24 throw BinderException(
25 std::format("Cannot infer field name for {}.", argument->toString()));
26 }
27 auto fieldName = input.optionalArguments[i];
28 if (fieldNameSet.contains(fieldName)) {
29 throw BinderException(std::format("Found duplicate field {} in STRUCT.", fieldName));
30 } else {
31 fieldNameSet.insert(fieldName);
32 }
33 fields.emplace_back(fieldName, argument->getDataType().copy());
34 }
35 const auto resultType = LogicalType::STRUCT(std::move(fields));
36 return FunctionBindData::getSimpleBindData(input.arguments, resultType);
37}
38
39void StructPackFunctions::compileFunc(FunctionBindData* /*bindData*/,
40 const std::vector<std::shared_ptr<ValueVector>>& parameters,

Callers

nothing calls this directly

Calls 9

getLogicalTypeIDMethod · 0.80
getDataTypeMethod · 0.80
emplace_backMethod · 0.80
sizeMethod · 0.45
castMethod · 0.45
toStringMethod · 0.45
containsMethod · 0.45
insertMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected