Re: SQL compatibility of Iceberg Expressions

2020-09-21 Thread Ryan Blue
If we can translate to an equivalent expression, then I think it is better to do that. Iceberg expressions don't support SQL semantics and it would be a big project to convert them. Afterward, we would just have more complicated expressions that are harder to maintain because SQL semantics are

Re: SQL compatibility of Iceberg Expressions

2020-09-18 Thread Owen O'Malley
No, you can translate these expressions, but you have to evaluate the entire expression. For example: "col1 = 'x' and col2 in (1,2)" becomes col1 = 'x' and col2 in (1,2) "not(col1 = 'x' and col2 in (1,2))" becomes (col1 != 'x' or col2 not in (1,2)) and col1 is not null and col2 is not null

Re: SQL compatibility of Iceberg Expressions

2020-09-18 Thread Ryan Blue
Are you saying that we can't fix this by rewriting expressions to translate from SQL to more natural semantics? On Fri, Sep 18, 2020 at 3:28 PM Owen O'Malley wrote: > In the SQL world, the second point isn't right. It is still the case that > not(equal("col", "x")) is notEqual("col", "x").

Re: SQL compatibility of Iceberg Expressions

2020-09-18 Thread Owen O'Malley
In the SQL world, the second point isn't right. It is still the case that not(equal("col", "x")) is notEqual("col", "x"). Boolean logic (well, three valued logic) in SQL is just strange relative to programming languages: - null *=* "x" -> null - null *is distinct from* "x" -> true -

Re: SQL compatibility of Iceberg Expressions

2020-09-18 Thread Ryan Blue
It would be nice to avoid the problem by changing the semantics of Iceberg’s notNull, but I don’t think that’s a good idea for 2 main reasons. First, I think that API users creating expressions directly expect the current behavior. It would be surprising to a user if a notEqual expression didn’t

Re: SQL compatibility of Iceberg Expressions

2020-09-18 Thread Owen O'Malley
I think that we should follow the SQL semantics to prevent surprises when SQL engines integrate with Iceberg. .. Owen On Thu, Sep 17, 2020 at 9:08 PM Shardul Mahadik wrote: > Hi all, > > I noticed that Iceberg's predicates are not compatible with SQL predicates > when it comes to handling NULL

SQL compatibility of Iceberg Expressions

2020-09-17 Thread Shardul Mahadik
Hi all, I noticed that Iceberg's predicates are not compatible with SQL predicates when it comes to handling NULL values. In SQL, if any of the operands of a scalar comparison predicate is NULL, then the resultant truth value of the predicate is UNKNOWN. e.g. `SELECT NULL != 1` will return a NULL