SeaQL / otter-sql

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

Design the instruction set #9

Closed Samyak2 closed 2 years ago

Samyak2 commented 2 years ago

8 added an empty Instruction enum. This needs to be populated with the actual instruction set. A basic instruction set is needed at this stage to go ahead with the implementation. Initial ideas for the instructions can be found in this discussion: https://github.com/SeaQL/summer-of-code/discussions/11#discussioncomment-2817842

Samyak2 commented 2 years ago

Here's a design I thought of:

Notations

tyt2y3 commented 2 years ago

Makes a lot of sense! Please go ahead. @shpun817 do you have some thoughts?

shpun817 commented 2 years ago

Looks good! Using fixed numbers of arguments definitely helps simplify things at operation, so I think it's a good idea.

For the rest of the questions, I'm afraid I can't give concrete answers yet, maybe take note of them first and proceed whereas possible?

Nice work overall!

Samyak2 commented 2 years ago

Thank you, I'm working on the implementation starting with the data structures for the register.

Also, I realized now that I missed considering GROUP BY. I will think about how to implement that and update the instruction set if needed.

tyt2y3 commented 2 years ago

Actually GROUP BY and other aggregates is yet another stage in the execution pipeline that should be reasonably easy to add later on. Good if you can think ahead though.

Samyak2 commented 2 years ago

I have added a few instructions (ProjectAggregate, GroupBy and Having) for GROUP BY and aggregations in the "General instructions" section above.

Reference: https://www.postgresql.org/docs/current/tutorial-agg.html

Samyak2 commented 2 years ago

Found something that cannot be implemented using the current instruction set: https://www.postgresql.org/docs/current/queries-union.html. I'll add Intersect and Difference to support this.