Simplify expressions passed to table functions#16388
Conversation
jonathanc-n
left a comment
There was a problem hiding this comment.
We can either support this for now and have a comment to delete it later when we support references to existing columns or not go forward with it.
| .get(name) | ||
| .cloned() | ||
| .ok_or_else(|| plan_datafusion_err!("table function '{name}' not found"))?; | ||
| let dummy_schema = DFSchema::empty(); |
There was a problem hiding this comment.
I think we eventually want to reference existing columns
For example:
SELECT * FROM t, range(t.id, t.id + 5);
I think the solution to this instead would be to have the a ExprSimplifier optimizer rule where it can reference the column values from the LATERAL statement. @Lordworms WDYT?
There was a problem hiding this comment.
I agree long term it would be great to have table functions support referencing other relations.
However, we would need to update the API more than just this -- right now TableFunctions have no way of getting inputs (they return TableProviders)
We would have to work out what the API would look like if they got an input (perhaps they get an input ExecutonPlan)
As you mention, we would also probably have to figure out planning for LATERALs, etc
Which issue does this PR close?
Rationale for this change
Table functions don't need to special case
Casts of literals or other constructs that could be simplified.What changes are included in this PR?
Apply expression simplification to table functions.
Are these changes tested?
Yes, added a sqllogictest
Are there any user-facing changes?
Yes, more queries should be supported.