I've always been curious about how SQL engines actually work.
So I built a minimum viable SQL engine in Go.
- Supports CSV files as tables
- Supports SELECT, FROM, WHERE, LIMIT
It's very simple:
1. Parses query string
2. Converts it into an AST representation
3. Executes the query against the CSV
4. Returns the results
You can see this post for the start of a guide in implementing something very similar "Writing a SQL database from scratch in Go":
https://notes.eatonphil.com/database-basics.html
(Use the tag "sql" to find the later parts. Sadly not linked directly from that first one.)