Skip to content

Support IS UNKNOWN #1534

@mvzink

Description

@mvzink

Description

Currently, nom-sql seems to parse mycol IS UNKNOWN as a comparison between a column mycol and another column unknown, which fails with Parent of AliasTable node missing required column:

readyset> create table foo (id int auto_increment primary key, bar int);
Query OK, 0 rows affected (0.12 sec)

readyset> insert into foo (bar) values (null), (42);
Query OK, 2 rows affected (0.26 sec)

readyset> select * from foo where bar is unknown and id = 1;
+----+------+
| id | bar  |
+----+------+
|  1 | NULL |
+----+------+
1 row in set (0.08 sec)

readyset> create cache from select * from foo where bar is unknown and id = ?;
ERROR 1105 (HY000): Error during RPC (extend_recipe (in readyset-client/src/controller/rpc.rs:49:26)): SQL SELECT query 'q_a5294302e4a42829' couldn't be added: Operation unsupported: in readyset-mir/src/rewrite/predicate_pushup.rs:187:28: Parent of AliasTable node missing required column

Sqlparser parses it as an Expr::IsUnknown, and it doesn't seem to onerous to plumb that through the same way we do with IsNull.

Note that this is used in a number of SQLancer queries.

Change in user-visible behavior

IS UNKNOWN should work in CREATE CACHE statements, probably only for filter nodes and not cache keys.

Additionally, it would be nice if the error message seen here said which column was missing, which could be useful debug info next time we encounter such missing functionality/incomplete parsing.

Requires documentation change

Yes, we should probably more fully document operator/expression support in the docs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Low priorityCreated by Linear-GitHub Sync

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions