SeaQL / otter-sql

🦦 An Embeddable SQL Executor in Rust
Apache License 2.0
26 stars 2 forks source link

`sqlparser` integration and code generation #13

Closed Samyak2 closed 2 years ago

Samyak2 commented 2 years ago

Tracking issue for parser integration

Links

Samyak2 commented 2 years ago

This includes:

tyt2y3 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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