| 12 | namespace function { |
| 13 | |
| 14 | static std::shared_ptr<Expression> rewriteFunc(const RewriteFunctionBindInput& input) { |
| 15 | DASSERT(input.arguments.size() == 1); |
| 16 | auto argument = input.arguments[0].get(); |
| 17 | auto expressionBinder = input.expressionBinder; |
| 18 | if (ExpressionUtil::isNullLiteral(*argument)) { |
| 19 | return expressionBinder->createNullLiteralExpression(); |
| 20 | } |
| 21 | auto uniqueExpressionName = |
| 22 | ScalarFunctionExpression::getUniqueName(KeysFunctions::name, input.arguments); |
| 23 | const auto& resultType = LogicalType::LIST(LogicalType::STRING()); |
| 24 | auto fields = common::StructType::getFieldNames(input.arguments[0]->dataType); |
| 25 | std::vector<std::unique_ptr<Value>> children; |
| 26 | for (auto field : fields) { |
| 27 | if (field == InternalKeyword::ID || field == InternalKeyword::LABEL || |
| 28 | field == InternalKeyword::SRC || field == InternalKeyword::DST) { |
| 29 | continue; |
| 30 | } |
| 31 | children.push_back(std::make_unique<Value>(field)); |
| 32 | } |
| 33 | auto resultExpr = std::make_shared<binder::LiteralExpression>( |
| 34 | Value{resultType.copy(), std::move(children)}, std::move(uniqueExpressionName)); |
| 35 | return resultExpr; |
| 36 | } |
| 37 | |
| 38 | static std::unique_ptr<Function> getKeysFunction(LogicalTypeID logicalTypeID) { |
| 39 | return std::make_unique<function::RewriteFunction>(KeysFunctions::name, |
nothing calls this directly
no test coverage detected