| 12 | namespace function { |
| 13 | |
| 14 | std::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 | |
| 34 | void StructExtractFunctions::compileFunc(FunctionBindData* bindData, |
| 35 | const std::vector<std::shared_ptr<ValueVector>>& parameters, |
nothing calls this directly
no test coverage detected