Closed Samyak2 closed 2 years ago
Here's a design I thought of:
%N
-> Nth register 'value'
-> A string <Value>
-> A crate::column::Value
[Type]
-> A type
View %N 'name'
name
. View
instead of the original Table
we decided in the discussion because:
Filter %N 'col name' OPERATOR <Value>
%N
Project %N 'col name'
col name
to the column selection. Not having any means *
. ProjectAggregate %N AGGR 'col name'
col name
with given aggregation to the column selection.GroupBy %N 'col name'
col name
to the grouped columns for the viewHaving %N AGGR 'col name' OPERATOR <Value>
Order %N 'col name' true|false
Limit %N num
Return %N
NewDatabase 'name' true|false
true
means IF NOT EXISTS
NewSchema 'name' true|false
true
means IF NOT EXISTS
TableDef %T 'name'
name
and stores the temporary metadata in %T
ColumnDef %C 'col name' [Type]
ColumnOption %C OPTION
NOT NULL
, etc.) to the ColumnDef
at %C
AddColumn %T %C
TableDef
and a View
NULL
or the default value (error if it's not nullable and a default is given). NewTable %T
RemoveColumn %T 'col name'
RenameColumn %T 'old name' 'new name'
sql-parser
AST. I don't know if it makes sense to break down the AST into these instructions which itself construct a data structure again instruction by instruction. Could be a better idea to just say NewTable %T (sqlparser CreateTable AST)
.
InsertDef %V %I
%V
Column %I 'col name'
name
RowDef %I %R
AddValue %R <Value>
<Value>
at this step Insert %I
Update %N 'col name' <Value>
%N
can have a view or a filter over a view. Union %I1 %I2 %O
%I1
and %I2
View
in %O
CrossJoin %I1 %I2 %O
Filter
, RemoveColumn
, RenameColumn
to get it to the correct shape NaturalJoin %I1 %I2 %O
Filter
to remove them if needed Makes a lot of sense! Please go ahead. @shpun817 do you have some thoughts?
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!
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.
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.
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
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.
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