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)
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)
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