I got some very nice feedback from the first part of this series. The main suggestions where to use some different parsing libraries like chumsky or u

Building a Simple DB in Rust - Part 2 - Basic Execution

submited by
Style Pass
2023-01-23 14:30:06

I got some very nice feedback from the first part of this series. The main suggestions where to use some different parsing libraries like chumsky or use an existing SQL parser like sqlparser-rs.

chumsky looks like it handles a lot of the error handling logic I had to do myself while still being defined in rust (no extra language). If I had known of this before I would have used it. Might switch to it later on if our grammar gets more involved. Thanks @hjvt@hachyderm.io for the recommendation!

sqlparser-rs on the other hand looks very well maintained and handles many existing SQL dialects. If this was not a toy project I would have probably started off with this to get going faster without writing any parser logic.

To get started on execution let's make a new crate for it with cargo new sql_jr_execution. We will need the parser crate for our types we made and some other workspace dependencies.

Since we will need to operate on tables, lets start by defining our table type. For now, we will only deal with in memory execution. Soon enough we can handle reading from disk.

Leave a Comment