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

Add support for DEFAULT keyword for INSERT statement #6331

Closed
BoseSean opened this issue Aug 5, 2019 · 6 comments · Fixed by #33141
Closed

Add support for DEFAULT keyword for INSERT statement #6331

BoseSean opened this issue Aug 5, 2019 · 6 comments · Fixed by #33141
Assignees
Labels
easy task Good for first contributors feature

Comments

@BoseSean
Copy link

BoseSean commented Aug 5, 2019

Use case

create table table1
(
    field1 Int32,
    field2 Int32,
    field3 Int32 default CAST(1337, 'Int32'),
    field4 Int32 default CAST(1337, 'Int32')
)engine = MergeTree() PARTITION BY field1 
ORDER BY (field1, field2) 
SETTINGS index_granularity = 8192;

insert into table1 (field1, field3) values (5, DEFAULT)
insert into table1 values (5, DEFAULT, 10, DEFAULT)

Result:

field1 field2 field3 field4
5 0 1337 1337
5 0 10 1337

Additional context
With the DEFAULT keyword, insertion of data would have a bit more flexibility. And, let data with some missing values utilize bulk loading.

@filimonov
Copy link
Contributor

Sounds reasonable, supported by most of popular DBMS (including MySQL, Postgres, MsSQL etc)

@tavplubix
Copy link
Member

After #7215 NULL keyword can be used as DEFAULT if input_format_null_as_default=1 and column type is not Nullable

@alexey-milovidov
Copy link
Member

It can be implemented quite easily.

@alexey-milovidov alexey-milovidov added the easy task Good for first contributors label Jul 3, 2021
@0over
Copy link
Contributor

0over commented Nov 24, 2021

I would like to try this. @alexey-milovidov

@alexey-milovidov
Copy link
Member

@1over Do you have any troubles implementing it? Do you need help?

@0over
Copy link
Contributor

0over commented Dec 24, 2021

@alexey-milovidov no troubles yet, I was occupied with other things. I plan to finish it in the coming days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy task Good for first contributors feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants