Conversation
…inality type string
When chaining .lowCardinality().nullable() or .nullable().lowCardinality(),
the SDK correctly produces the type string LowCardinality(Nullable(X)).
However, it also set nullable: true in the column modifiers metadata.
The backend checks modifiers.nullable and wraps the type with Nullable()
if the type string doesn't start with 'Nullable('. Since
LowCardinality(Nullable(X)) starts with 'LowCardinality(', the backend
would double-wrap it into Nullable(LowCardinality(Nullable(X))), which
ClickHouse rejects.
Fix: omit the nullable modifier flag when nullable is already encoded
inside the LowCardinality type string wrapper.
Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d247b-1dfc-764a-ae09-697511e5209f
0f860b5 to
6c35e51
Compare
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
When chaining
t.string().lowCardinality().nullable(), the SDK correctly produces the ClickHouse type stringLowCardinality(Nullable(String)), but also setsnullable: truein the column modifiers metadata.The backend (
datasource_schema.py) checks whether to wrap the type withNullable()by testing if the type string starts with"Nullable(". SinceLowCardinality(Nullable(String))starts with"LowCardinality(", the check passes and the backend wraps it again, producingNullable(LowCardinality(Nullable(String)))— which ClickHouse rejects.Fix
Omit the
nullablemodifier flag from column metadata when nullable is already encoded inside theLowCardinality(...)type string wrapper. This applies to both chaining orders:.lowCardinality().nullable().nullable().lowCardinality()The type string itself remains correct (
LowCardinality(Nullable(X))), and the backend no longer redundantly wraps it.