Skip to content
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: base implementation of default value #246

Merged
merged 14 commits into from
Sep 21, 2022

Conversation

ygf11
Copy link
Contributor

@ygf11 ygf11 commented Sep 13, 2022

Which issue does this PR close?

Closes #249
Part of #252

Rationale for this change

Default value is a very useful feature.

What changes are included in this PR?

  • Support defining expr in column default value option when create table, and only support exprs which does not reference other columns, like 10, 1+1, now()..
  • Support returning default-value infos for show create xxx.
  • Support casting and filling missing columns whose default value option was defined when insert.
  • Fix and add tests.

Are there any user-facing changes?

  • Create Table can define default value option for columns.
  • Show create Table xxx will also return default value infos.
  • Insert can auto fill with default value option.

How does this change test

Unit tests.

@ygf11 ygf11 marked this pull request as ready for review September 15, 2022 01:06
@ygf11
Copy link
Contributor Author

ygf11 commented Sep 15, 2022

@waynexia @ShiKaiWi @jiacai2050 PTAL, it is ready for review.

@waynexia waynexia added feature New feature or request A-SQL Area: SQL layer labels Sep 15, 2022
Copy link
Member

@waynexia waynexia left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! The implementation is very clean 👍 I left some tiny comments

df_operator/src/visitor.rs Outdated Show resolved Hide resolved
interpreters/src/insert.rs Outdated Show resolved Hide resolved
interpreters/src/tests.rs Show resolved Hide resolved
sql/src/plan.rs Outdated Show resolved Hide resolved
sql/src/planner.rs Show resolved Hide resolved
server/src/http.rs Show resolved Hide resolved
ygf11 and others added 3 commits September 16, 2022 08:01
Co-authored-by: Ruihang Xia <waynestxia@gmail.com>
Co-authored-by: Ruihang Xia <waynestxia@gmail.com>
Co-authored-by: Ruihang Xia <waynestxia@gmail.com>
@jiacai2050 jiacai2050 changed the title feat: base implemment of default value feat: base implementation of default value Sep 16, 2022
common_types/src/column_schema.rs Outdated Show resolved Hide resolved
interpreters/src/insert.rs Outdated Show resolved Hide resolved
interpreters/src/insert.rs Outdated Show resolved Hide resolved
interpreters/src/tests.rs Outdated Show resolved Hide resolved
sql/src/planner.rs Show resolved Hide resolved
df_operator/src/visitor.rs Outdated Show resolved Hide resolved
common_types/src/tests.rs Outdated Show resolved Hide resolved
interpreters/src/insert.rs Show resolved Hide resolved
interpreters/src/tests.rs Outdated Show resolved Hide resolved
sql/src/planner.rs Outdated Show resolved Hide resolved
sql/src/planner.rs Outdated Show resolved Hide resolved
@jiacai2050
Copy link
Contributor

@ygf11 I have left another few comments, PLAT.

The general implementation is concise, good job!

@ygf11 ygf11 requested review from jiacai2050 and removed request for ShiKaiWi September 20, 2022 09:04
Copy link
Contributor

@jiacai2050 jiacai2050 left a comment

Choose a reason for hiding this comment

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

LGTM

@jiacai2050 jiacai2050 merged commit ed22bf9 into apache:main Sep 21, 2022
@ygf11 ygf11 deleted the simple-default-value branch September 21, 2022 03:35
chunshao90 pushed a commit to chunshao90/ceresdb that referenced this pull request May 15, 2023
* feat: base implemment of default value

* Add some unit tests

* Make lint happy

* replace CastExpr with TryCastExpr when filling default value

* Update df_operator/src/visitor.rs

Co-authored-by: Ruihang Xia <waynestxia@gmail.com>

* Update interpreters/src/insert.rs

Co-authored-by: Ruihang Xia <waynestxia@gmail.com>

* Update sql/src/plan.rs

Co-authored-by: Ruihang Xia <waynestxia@gmail.com>

* Add integration tests

* Fix minor comments

* Fix integration test

* Merge remote-tracking branch 'upstream/main' into simple-default-value

* Fix minor comments

* Improve conversion from Output to inner records

Co-authored-by: Ruihang Xia <waynestxia@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-SQL Area: SQL layer feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Base implemment of default value for columns
3 participants