Skip to content

feat(binder): add create table binding#16

Merged
loloxwg merged 3 commits intomainfrom
feat/create
Jul 4, 2023
Merged

feat(binder): add create table binding#16
loloxwg merged 3 commits intomainfrom
feat/create

Conversation

@loloxwg
Copy link
Copy Markdown
Member

@loloxwg loloxwg commented Jun 30, 2023

What problem does this PR solve?

add create table binding

Issue link: #8

What is changed and how it works?

Code changes

  • Has Rust code change
  • Has CI related scripts change

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Note for reviewer

  • check the bind context should be used
  • check if LogicalCreateTablePlan struct define is reasonable?
  • i had make some code format

@loloxwg loloxwg requested review from KKould and eliasyaoyc June 30, 2023 02:38
Comment thread src/binder/create.rs
};
Ok(plan)
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided code patch appears to be an implementation of the bind_create_table method in a Binder struct. Here are some observations and suggestions for improvement:

  1. It seems that the code is missing necessary import statements at the beginning. Make sure to include the required imports, such as super, Binder, lower_case_name, split_name, etc.

  2. Consider adding proper documentation or comments to describe the purpose and functionality of the bind_create_table method. This will make it easier for other developers (including yourself) to understand the code in the future.

  3. It's generally a good practice to handle potential errors gracefully. For example, when retrieving a table by name (self.context.catalog.get_table_by_name(table_name)), consider using the Result type along with proper error handling instead of directly calling .ok_or_else() and returning an Error. This will provide more information about the specific error that occurred during table retrieval.

  4. The code checks for duplicated column names using a HashSet. This is a valid approach, but it would be helpful to provide a more specific error message indicating which column names are duplicated.

  5. When mapping the columns from ColumnDef to Column, the line let mut col = Column::from(col); seems unnecessary since the Column::from function can directly return a new instance without needing to mutate it.

  6. Check if there are any additional validations or constraints that need to be implemented. For example, you may want to verify the data types or enforce certain properties on the columns being created.

  7. Consider adding tests to cover different scenarios, such as creating a table with no columns, creating a table with duplicate columns, etc. This will ensure the correctness of the implementation and help catch any potential issues.

Remember that these suggestions are general guidelines, and your specific project requirements may vary.

@github-actions
Copy link
Copy Markdown

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

Copy link
Copy Markdown
Member

@KKould KKould left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some details are problematic, but the overall logic is okay

Comment thread src/binder/create.rs Outdated
Comment thread src/binder/mod.rs Outdated
name.0
.iter()
.map(|ident| Ident::new(ident.value.to_lowercase()))
.collect::<Vec<_>>(),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

collect_vec()

Comment thread src/catalog/column.rs
}

impl From<&ColumnDef> for Column {
fn from(cdef: &ColumnDef) -> Self {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable name definition is too easy to confuse!

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jul 4, 2023

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

@loloxwg loloxwg merged commit 55dd49a into main Jul 4, 2023
loloxwg added a commit that referenced this pull request Jul 12, 2023
* refactor(catalog): refactor the implementation of Catalog and remove the two levels of Schema and DataBase for simplification

* doc: delete wrong comment

* feat: using a global nature id generator for ordered de duplication id generation to avoid third-party dependencies

* fix(tests): ignore test_id_generator

* feat(ci): Change toolchain. (#14)

- Configure Gpt code review bot.

* feat(binder): add create table binding (#16)

* style(fmt): code format

* feat(binder): add create table binding

* feat(style): make code clean

---------

Co-authored-by: Xwg <xuanwei.zhang@gatech.com>

* feat(flow): execute the sql process to arrive at the logic plan and print it (#17)

- add create table bind test
- change logic of main function

Co-authored-by: Xwg <xuanwei.zhang@gatech.com>

* feat(catalog): 新增types mod以及catalog mod.
- catalog 存储了库表列之间的关系结构
- types   类型系统表示了数据库字段的类型

* feat(catalog): 修改types接口模式,并实现在ColumnDesc 的new 方法中
- 更改函数签名中的&String到&str
- 取消类型中的new方法,并将其归入ColumnDesc 的new 方法中统一实现

* feat(style): 修改文件命名方式,函数名称,提升可读性

* feat(catalog): 完成基本的catalog用来存储数据库元数据(库表名字段信息映射关系)

* feat(binder): 完成create table binder
- binder用来将解析后生成的 AST 和 Schema 信息绑定起来,检查输入的名称是否合法、是否有重复、有歧义
- catalog引入锁机制,创建column catalog流程改变
- 类型系统变化为sqlparser的DataTypeKind,并实现DataTypeExt trait,方便进行nullable设置

* fix(catalog): mutex 引入parking_lot,避免std库中的lock unwrap
- 加入一些内联标志

* feat: executor graph.

* fix cross meta-pipeline dependencies.

* fix: all_pipeline miss.

* refactor: pipeline event.

---------

Co-authored-by: Kould <2435992353@qq.com>
Co-authored-by: Xwg <xuanwei.zhang@gatech.edu>
Co-authored-by: Xwg <xuanwei.zhang@gatech.com>
@KKould KKould deleted the feat/create branch August 27, 2024 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants