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

Sqlsmith: Generate Type Castings #3878

Closed
2 tasks done
Tracked by #2571
neverchanje opened this issue Jul 14, 2022 · 2 comments
Closed
2 tasks done
Tracked by #2571

Sqlsmith: Generate Type Castings #3878

neverchanje opened this issue Jul 14, 2022 · 2 comments
Assignees

Comments

@neverchanje
Copy link
Contributor

neverchanje commented Jul 14, 2022

We can reversely build the casting map from src/frontend/src/expr/type_inference/cast.rs CAST_MAP like what we did for the functions table. Then we can randomly choose a viable cast in gen_expr.

The reverse expr building path:

  1. First we know exactly the select item's returning type.
  2. Use gen_expr to randomly select an expr that will return the target type. At a certain probability, it tries to generate cast.
  3. Reversely find the source type that is able to cast to the target type, according to the cast map.
  4. Generate the cast.

Additionally, the non-viable castings are also needed to test. For example, SELECT bool 'test'. We will now fail on this SQL.

@xiangjinwu
Copy link
Contributor

related: #1632

@kwannoel
Copy link
Contributor

kwannoel commented Aug 5, 2022

Completed by #4419 . Track non viable castings separately here: #4468 .

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

No branches or pull requests

3 participants