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