Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(planner_v2): add type checker #717

Merged
merged 9 commits into from
Oct 17, 2022
Merged

feat(planner_v2): add type checker #717

merged 9 commits into from
Oct 17, 2022

Conversation

wangrunji0408
Copy link
Member

@wangrunji0408 wangrunji0408 commented Oct 17, 2022

This PR adds a type checker to the new planner. It is implemented as an egg analysis. Each Expr node will be associated with a type analysis result, which can be either a type or an error. If a type error is found after constructing a node, the binder will return the error:

> create table t (a int, b boolean);
created
in 0.004s
> \v2
switched to planner v2
in 0.000s
> select a + b from t;
bind error: type error: no function for +[Int32, Bool]

Note that the type checker in this PR is far from complete. For example, it only allows binary operations on values of the same type (INT + INT ✅), and doesn't support implicit type cast yet (INT + DOUBLE ❌). I've added some failing tests to show these limits. They will be fixed in the future.

Signed-off-by: Runji Wang <wangrunji0408@163.com>
Signed-off-by: Runji Wang <wangrunji0408@163.com>
Signed-off-by: Runji Wang <wangrunji0408@163.com>
Signed-off-by: Runji Wang <wangrunji0408@163.com>
Signed-off-by: Runji Wang <wangrunji0408@163.com>
Signed-off-by: Runji Wang <wangrunji0408@163.com>
Signed-off-by: Runji Wang <wangrunji0408@163.com>
@wangrunji0408 wangrunji0408 requested review from skyzh and xxchan October 17, 2022 12:45
Signed-off-by: Runji Wang <wangrunji0408@163.com>
@wangrunji0408 wangrunji0408 merged commit 686144b into main Oct 17, 2022
@wangrunji0408 wangrunji0408 deleted the wrj/type-check branch October 17, 2022 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants