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

What are use cases for non-nullable types? #332

Closed
mbasmanova opened this issue Sep 13, 2022 · 6 comments
Closed

What are use cases for non-nullable types? #332

mbasmanova opened this issue Sep 13, 2022 · 6 comments
Labels
awaiting-user-input This issue is waiting on further input from users question Further information is requested

Comments

@mbasmanova
Copy link

mbasmanova commented Sep 13, 2022

Folks, the type systems allows to specify nullability for each type. In SQL, all types are nullable, hence, I'm curious what's the use case for non-nullable types.

https://substrait.io/types/type_system/

Describes whether values of this type can be null. Note that null is considered to be a special value of a nullable type, rather than the only value of a special null type.

Context: substrait-io/substrait-validator#52 (comment)

@mbasmanova mbasmanova added the question Further information is requested label Sep 13, 2022
@jvanstraten
Copy link
Contributor

I think you meant "non-nullable" in your issue title. Also, link to the thread that spawned this: substrait-io/substrait-validator#52 (comment)

@mbasmanova mbasmanova changed the title What are use cases for nullable types? What are use cases for non-nullable types? Sep 13, 2022
@mbasmanova
Copy link
Author

@jvanstraten You are correct. Thank you for pointing this out. Updated the title and description.

@jacques-n
Copy link
Contributor

There are a number of cases where optimizers can make smarter decisions if they can know that the data cannot have nulls. Additionally, many systems have representation and execution optimizations with non-nullable scenarios. Most databases have the ability to declare fields as non-nullable.

@julianhyde
Copy link

Calcite allows nullable and non-nullable types. But it might have been better if it had represented nullability as a constraint, rather than part of the type. A column that goes into a filter nullable can come out not-nullable. That's more of a change of constraint rather than a change in representation.

@westonpace
Copy link
Member

Can we close this? I think the answer has been given (it's not classic SQL but it can allow optimizers and engines to make more intelligent decisions and some engines support it).

@westonpace westonpace added the awaiting-user-input This issue is waiting on further input from users label Mar 8, 2023
@cpcloud
Copy link
Contributor

cpcloud commented Mar 8, 2023

ClickHouse is an engine that makes rather heavy use of non nullable types. All naked types in clickhouse e.g., Int64 are not nullable.

@cpcloud cpcloud closed this as completed Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-user-input This issue is waiting on further input from users question Further information is requested
Projects
None yet
Development

No branches or pull requests

6 participants