reallocf commented on a change in pull request #5326:
URL: https://github.com/apache/incubator-pinot/pull/5326#discussion_r419042856
##########
File path:
pinot-core/src/test/java/org/apache/pinot/core/data/function/DefaultFunctionEvaluatorTest.java
##########
@@ -34,69 +35,72 @@
@Test
public void testExpressionWithColumn()
throws Exception {
- Method method = MyFunc.class.getDeclaredMethod("reverseString",
String.class);
- FunctionRegistry.registerStaticFunction(method);
- FunctionInfo functionInfo = FunctionRegistry.resolve("reverseString", new
Class<?>[]{Object.class});
+ MyFunc myFunc = new MyFunc();
+ FunctionRegistry functionRegistry = new FunctionRegistry(
+
Collections.singletonList(myFunc.getClass().getDeclaredMethod("reverseString",
String.class)));
+ FunctionInfo functionInfo = functionRegistry.resolve("reverseString", new
Class<?>[]{Object.class});
System.out.println(functionInfo);
String expression = "reverseString(testColumn)";
- DefaultFunctionEvaluator evaluator = new
DefaultFunctionEvaluator(expression);
+ DefaultFunctionEvaluator evaluator = new
DefaultFunctionEvaluator(expression, functionRegistry);
Assert.assertEquals(evaluator.getArguments(),
Lists.newArrayList("testColumn"));
GenericRow row = new GenericRow();
for (int i = 0; i < 5; i++) {
String value = "testValue" + i;
row.putField("testColumn", value);
Object result = evaluator.evaluate(row);
- Assert.assertEquals(result, new
StringBuilder(value).reverse().toString());
+ Assert.assertEquals(result, myFunc.reverseString(value));
Review comment:
There's some testing value to keeping the `new StringBuilder...` - will
change back
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]