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

[doc] NOT NULL in ALTER TABLE ADD COLUMNS is not mentioned in the doc #3360

Open
li-boxuan opened this issue Jul 10, 2024 · 3 comments · May be fixed by #3401
Open

[doc] NOT NULL in ALTER TABLE ADD COLUMNS is not mentioned in the doc #3360

li-boxuan opened this issue Jul 10, 2024 · 3 comments · May be fixed by #3401
Labels
bug Something isn't working

Comments

@li-boxuan
Copy link

li-boxuan commented Jul 10, 2024

I understand this might be by design, but https://docs.delta.io/latest/delta-batch.html#add-columns could be made more clear. It currently says,

By default, nullability is true.

image

which gives me an impression that one can override the nullability, but I got

spark-sql (default)> ALTER TABLE basic ADD COLUMNS (col1_nonnull2 integer NOT NULL);
[DELTA_OPERATION_NOT_ALLOWED] Operation not allowed: `NOT NULL in ALTER TABLE ADD COLUMNS` is not supported for Delta tables

Also, note that due to #831, you cannot change an existing nullable column to non-nullable. This means the ONLY way to have a non-nullable column is to do so when creating the table.

Version:

        :: modules in use:
        io.delta#delta-spark_2.12;3.1.0 from central in [default]
        io.delta#delta-storage;3.1.0 from central in [default]
        org.antlr#antlr4-runtime;4.9.3 from central in [default]
@li-boxuan li-boxuan added the bug Something isn't working label Jul 10, 2024
@rishabhchaudha
Copy link

rishabhchaudha commented Jul 16, 2024

I've noticed that an error is intentionally thrown when specifying 'Not Null' in the code. This decision should be by design , especially during schema alterations where the default value for new columns is logically null.

image

@li-boxuan
Copy link
Author

This decision should be by design , especially during schema alterations where the default value for new columns is logically null.

Yeah I agree with that. I would consider it as a glitch in the doc to be improved.

@li-boxuan li-boxuan changed the title [BUG] Operation not allowed: NOT NULL in ALTER TABLE ADD COLUMNS is not supported for Delta tables [BUG] NOT NULL in ALTER TABLE ADD COLUMNS is not mentioned in the doc Jul 16, 2024
@li-boxuan li-boxuan changed the title [BUG] NOT NULL in ALTER TABLE ADD COLUMNS is not mentioned in the doc [doc] NOT NULL in ALTER TABLE ADD COLUMNS is not mentioned in the doc Jul 16, 2024
@MrPowers
Copy link
Collaborator

@li-boxuan - thanks for creating this issue. Would you like to submit a pull request to update the language of the docs?

@li-boxuan li-boxuan linked a pull request Jul 22, 2024 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants