| 11 | namespace function { |
| 12 | |
| 13 | static std::shared_ptr<Expression> rewriteFunc(const RewriteFunctionBindInput& input) { |
| 14 | DASSERT(input.arguments.size() == 2); |
| 15 | auto uniqueExpressionName = |
| 16 | ScalarFunctionExpression::getUniqueName(NullIfFunction::name, input.arguments); |
| 17 | const auto& resultType = input.arguments[0]->getDataType(); |
| 18 | auto caseExpression = std::make_shared<CaseExpression>(resultType.copy(), input.arguments[0], |
| 19 | uniqueExpressionName); |
| 20 | auto binder = input.expressionBinder; |
| 21 | auto whenExpression = binder->bindComparisonExpression(ExpressionType::EQUALS, input.arguments); |
| 22 | auto thenExpression = binder->createNullLiteralExpression(); |
| 23 | thenExpression = binder->implicitCastIfNecessary(thenExpression, resultType.copy()); |
| 24 | caseExpression->addCaseAlternative(whenExpression, thenExpression); |
| 25 | return caseExpression; |
| 26 | } |
| 27 | |
| 28 | function_set NullIfFunction::getFunctionSet() { |
| 29 | function_set functionSet; |
no test coverage detected