substrait
substrait copied to clipboard
Add support for "unbound" or "unresolved" expressions
Many implementations have a notion of an "unbound expression". This is basically the difference between something like "a + b" and "field(3):i32 + field(0):i32". In an unbound expression we do not know the types of the AST nodes. We cannot verify function implementations (e.g. the expression may be asking to add a number to a uuid, which is invalid, but we don't know that). We also may have to deal with unresolved references (e.g. a reference to a field named "foo")
Being able to serialize these sorts of expressions can be useful in the very front end of a query system where users are entering queries and the schema isn't necessarily known.
In order to keep changes minimal I think we would only need a few modifications:
- Canonicalize the fact that there is a type class called "unknown" which can be used in place of any other type in a function call (e.g. add(unknown_type, i32) is legal)
- Add a "NamedExpression" which is part of the
Expression::rex_type
and is very similar to NamedTable (e.g. it is expected some downstream component will resolve this using some catalog or external knowledge that is known to both producer and consumer).