HaoYang670 commented on issue #4615:
URL:
https://github.com/apache/arrow-datafusion/issues/4615#issuecomment-1352471920
BTW, the ` type coercion` and other rules for correctness should be moved in
front of the optimizer.
It is the duty of the optimizer to make the query plan to achieve better
performance, but not to correct the query.
In another word, the Datafusion should work even if we remove the optimizer.
It could be good if we could extract the `type coercion` from the optimizer
and put it into a type checker for correcting the query. The pipeline could be
very similar to a compiler:
```
SQL ---(parser)---> logical plan ---(type checker)---> verified logical plan
---(logical optimizer)---> optimized logical plan ...
| |
\|/ \|/
Syntax error Type error
```
If we could do this, one different idea of the return type of the optimizer
is that I think the optimizer should return an `Option<LogicalPlan>` instead of
`Result<Option<LogicalPlan>>` or `Result<LogicalPlan>`. Because we should not
allow an error (even if it is an `Internal` Error) returned from the optimizer,
with the assumption that the input plan has been verified. The variant of the
returned values should only be:
1. None: when the plan cannot be optimized.
2. Some(plan): return the optimized plan
3. panic!(..): there is a bug in the optimizer.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]