def test_when_function_executor_with_a_child_should_allow_chaining(self):
     expression = FunctionExpression(lambda x: x)
     child = FunctionExpression(lambda x: list(map(lambda t: t + 1, x)))
     expression.append_child(child)
     values = [1, 2, 3]
     actual = expression.evaluate(values)
     expected = [2, 3, 4]
     self.assertEqual(expected, actual)
예제 #2
0
 def test_when_function_executor_with_a_child_should_allow_chaining(self):
     expression = FunctionExpression(lambda x: pd.DataFrame(x))
     child = FunctionExpression(lambda x: x + 1)
     expression.append_child(child)
     values = Batch(pd.DataFrame([1, 2, 3]))
     actual = expression.evaluate(values)
     expected = Batch(pd.DataFrame([2, 3, 4]))
     self.assertEqual(expected, actual)
예제 #3
0
    def visitUdfFunction(self, ctx: evaql_parser.UdfFunctionContext):
        udf_name = None
        udf_args = None
        if ctx.simpleId():
            udf_name = self.visit(ctx.simpleId())
        else:
            LoggingManager().log('UDF function name missing.',
                                 LoggingLevel.ERROR)

        udf_args = self.visit(ctx.functionArgs())
        func_expr = FunctionExpression(None, name=udf_name)
        for arg in udf_args:
            func_expr.append_child(arg)
        return func_expr