Skip to content
This repository has been archived by the owner on May 12, 2024. It is now read-only.

sqlparser integration and code generation #13

Closed
Samyak2 opened this issue Jun 26, 2022 · 4 comments · Fixed by #14
Closed

sqlparser integration and code generation #13

Samyak2 opened this issue Jun 26, 2022 · 4 comments · Fixed by #14

Comments

@Samyak2
Copy link
Collaborator

Samyak2 commented Jun 26, 2022

Tracking issue for parser integration

Links

@Samyak2 Samyak2 mentioned this issue Jun 26, 2022
4 tasks
@Samyak2
Copy link
Collaborator Author

Samyak2 commented Jul 19, 2022

This includes:

  • Use sqlparser to generate AST from SQL code. This part is simple.
  • Code generation: use the AST to generate intermediate code using instruction set #12. This will be tricky and will require many tests to ensure correctness.
    • This will be done in phases:
      1. CREATE DATABASE and CREATE SCHEMA
      2. Convert sqlparser's Value to our Value.
      3. Convert sqlparser's Expr to our Expr.
      4. CREATE TABLE: Columns with name and types only and with IF NOT EXISTS.
      5. INSERT: into table, simple values.
      6. SELECT: from a table, filter using WHERE.
      7. UPDATE: a table with simple expr.
      8. DELETE: a table with simple expr.
      9. DROP TABLE, DROP SCHEMA, DROP DATABASE
    • All other SQL features will be on top of these basic statements. They will be implemented once the execution for these basic statements is done.

@Samyak2 Samyak2 changed the title sqlparser integration sqlparser integration and code generation Jul 19, 2022
@Samyak2 Samyak2 mentioned this issue Jul 19, 2022
4 tasks
@tyt2y3
Copy link
Member

tyt2y3 commented Jul 21, 2022

Actually, can we reuse sqlparser's Expr (we simply re-export them) ? May be we should also use sqlparser's Value internally, or at least make them inter-convertable?

Would that save us some time & effort?

@Samyak2
Copy link
Collaborator Author

Samyak2 commented Jul 22, 2022

Actually, can we reuse sqlparser's Expr (we simply re-export them) ? May be we should also use sqlparser's Value internally, or at least make them inter-convertable?

Would that save us some time & effort?

sqlparser::ast::Value may be good for representation of values in a query, but I don't think it's appropriate for the executor. As an example, the only number variant is stored as a string. So everytime we need to read or do operations on them, we'll need to convert it to an appropriate numeric type. While converting to our own Value, I have handled this, so that we do not have to bother about this in the executor.

As for Expr, some of its variants store a Value. To make it consistent, we should make our own Expr that stores our Value. I believe this won't add too much maintenance overhead because extending it will be simply adding a new variant and changing impl TryFrom<sqlparser::ast::Expr> to use it. It also very clearly describes all the operations that we will support.

@tyt2y3
Copy link
Member

tyt2y3 commented Jul 23, 2022

Okay cool. Thank you for the explanation. I am looking forward to some unit tests!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants