Skip to content

Commit

Permalink
using BaseScalarUnivariateMacroFunctionExpr
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavbhole committed Sep 20, 2023
1 parent 77e964b commit fa4d4b7
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.apache.druid.math.expr;

import com.google.common.collect.Lists;
import org.apache.druid.java.util.common.StringUtils;
import org.apache.druid.segment.column.TypeStrategy;

Expand Down Expand Up @@ -153,7 +154,8 @@ public static class StringDecodeBase64UTFExprMacro implements ExprMacroTable.Exp
@Override
public Expr apply(List<Expr> args)
{
return new StringDecodeBase64UTFExpression(args);
validationHelperCheckArgumentCount(args, 1);
return new StringDecodeBase64UTFExpression(args.get(0));
}

@Override
Expand All @@ -162,18 +164,17 @@ public String name()
return NAME;
}

final class StringDecodeBase64UTFExpression extends ExprMacroTable.BaseScalarMacroFunctionExpr
final class StringDecodeBase64UTFExpression extends ExprMacroTable.BaseScalarUnivariateMacroFunctionExpr
{
public StringDecodeBase64UTFExpression(List<Expr> args)
public StringDecodeBase64UTFExpression(Expr arg)
{
super(NAME, args);
validationHelperCheckArgumentCount(args, 1);
super(NAME, arg);
}

@Override
public ExprEval eval(ObjectBinding bindings)
{
ExprEval<?> toDecode = args.get(0).eval(bindings);
ExprEval<?> toDecode = arg.eval(bindings);
if (toDecode.value() == null) {
return ExprEval.of(null);
}
Expand All @@ -183,7 +184,7 @@ public ExprEval eval(ObjectBinding bindings)
@Override
public Expr visit(Shuttle shuttle)
{
return shuttle.visit(apply(shuttle.visitAll(args)));
return shuttle.visit(apply(shuttle.visitAll(Lists.newArrayList(arg))));
}

@Nullable
Expand All @@ -196,13 +197,13 @@ public ExpressionType getOutputType(InputBindingInspector inspector)
@Override
public boolean isLiteral()
{
return args.get(0).isLiteral();
return arg.isLiteral();
}

@Override
public boolean isNullLiteral()
{
return args.get(0).isNullLiteral();
return arg.isNullLiteral();
}

@Nullable
Expand Down

0 comments on commit fa4d4b7

Please sign in to comment.