Replies: 2 comments 1 reply
-
I think it's ok to return different error if the argument order is different. The bug is that even for same order, simplified eval returns different error from common eval. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The problem
The evaluation result of an expression may be affected by the order we evaluate arguments if the function has default NULL behavior and there are exceptions from one argument and NULLs from another arguments at the same rows.
For example, imagine we evaluate two expressions
add(g(c0), h(c1))
andadd(h(c1), g(c0))
, and assume the evaluation ofg(c0)
throws at row 0, andh(c1)
returns NULL at row 0.add(g(c0), h(c1))
would throw at row 0 immediately when it evaluates the subexpressiong(c0)
. On the other hand,add(h(c1), g(c0))
returns NULL at row 0 because it evaluatesh(c1)
first, gets a NULL at row 0, and remove row 0 from the selected rows before evaluatingg(c0)
(such thatg(c0)
would not be evaluated on row 0). A real expression to reproduce this discrepancy is the following:Context
default_null_function(c0, throw_error(c1), NULL)
. The common evaluation path constant-folds the expression by the default NULL, while the simplified evaluation path evaluates the expression and throws at the second subexpression.Proposed solution
One solution we're proposing is to hold the exceptions in the error vector in context (i.e.,
EvalCtx::errors_
) when evaluating each argument of an expression. After evaluating all arguments, if the function has default NULL behavior, we check whether there are NULLs from one argument at the same rows as exceptions from another argument. In such as case, we remove the exceptions at those rows. This will makeadd(g(c0), h(c1))
andadd(h(c1), g(c0))
in the example above both return NULL at row 0.Pros
Cons
Discussion
I'm wondering whether there are concerns about the proposed solution and what other options we may have.
Beta Was this translation helpful? Give feedback.
All reactions