-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support multi ordered primary key #633
Conversation
Signed-off-by: Shmiwy <wyf000219@126.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM, good work!
For the bind_create_table
part, I suggest to reorganize the code, so that it can be much clearer to readers.
- Firstly, get the pk constraints ident vec from
get_extra_pks
, likevec!["a"]
- Then, replace vec of ident to vec of column id, e.g.,
vec![ColumnId(1)]
. May use hashmap in the process to accelerate lookups. We call thisordered_pks_from_constraint
. - After that, iterate all columns, and generate a new set of
ordered_pks_from_columns
fromis_primary
property. - If both
ordered_pks_from_constraint
andordered_pks_from_columns
are not empty, return error. Ifordered_pks_from_columns
has more than 1 elements, return error (if you want). - Then we can get the final
ordered_pks
from eitherordered_pks_from_constraint
orordered_pks_from_columns
.
@@ -124,10 +140,14 @@ mod tests { | |||
let catalog = Arc::new(RootCatalog::new()); | |||
let mut binder = Binder::new(catalog.clone()); | |||
let sql = " | |||
create table t1 (v1 int not null, v2 int); | |||
create table t1 (v1 int not null, v2 int); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can have planner test in the future 🤣 I guess writing this test case must be painful.
table_name.clone(), | ||
column_descs.to_vec(), | ||
false, | ||
ordered_pk_ids, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ordered_pk_ids
also needs to be persisted to disk in manifest.rs CreateTableEntry
. We can do this in later PRs.
Signed-off-by: Shmiwy <wyf000219@126.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest LGTM, good work!
Signed-off-by: Shmiwy <wyf000219@126.com>
Signed-off-by: Shmiwy wyf000219@126.com
try to implementation #625
at this moment, I just append
ordered_pk_ids
totableCatalog
withoud usingis_primary
filed inColumnDesc
. It will make removingis_primary
in the future easier.