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

Function rewriteFunc

src/function/utility/nullif.cpp:13–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11namespace function {
12
13static 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
28function_set NullIfFunction::getFunctionSet() {
29 function_set functionSet;

Callers 2

createQueryNodeMethod · 0.50

Calls 8

getUniqueNameFunction · 0.85
getDataTypeMethod · 0.80
sizeMethod · 0.45
copyMethod · 0.45
addCaseAlternativeMethod · 0.45

Tested by

no test coverage detected