From fa4d4b7551f9f50674c266353e342a54e9d77d48 Mon Sep 17 00:00:00 2001 From: Pranav Bhole Date: Mon, 18 Sep 2023 15:09:09 -0700 Subject: [PATCH] using BaseScalarUnivariateMacroFunctionExpr --- .../druid/math/expr/BuiltInExprMacros.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/processing/src/main/java/org/apache/druid/math/expr/BuiltInExprMacros.java b/processing/src/main/java/org/apache/druid/math/expr/BuiltInExprMacros.java index 39b56f7966fb..117495f0c139 100644 --- a/processing/src/main/java/org/apache/druid/math/expr/BuiltInExprMacros.java +++ b/processing/src/main/java/org/apache/druid/math/expr/BuiltInExprMacros.java @@ -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; @@ -153,7 +154,8 @@ public static class StringDecodeBase64UTFExprMacro implements ExprMacroTable.Exp @Override public Expr apply(List args) { - return new StringDecodeBase64UTFExpression(args); + validationHelperCheckArgumentCount(args, 1); + return new StringDecodeBase64UTFExpression(args.get(0)); } @Override @@ -162,18 +164,17 @@ public String name() return NAME; } - final class StringDecodeBase64UTFExpression extends ExprMacroTable.BaseScalarMacroFunctionExpr + final class StringDecodeBase64UTFExpression extends ExprMacroTable.BaseScalarUnivariateMacroFunctionExpr { - public StringDecodeBase64UTFExpression(List 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); } @@ -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 @@ -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