-
Notifications
You must be signed in to change notification settings - Fork 216
fix(DBI-1096 - clickhouse destination connector): Honor nullability for destination_type overrides in normalize #4783
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -168,6 +168,11 @@ func (t *NormalizeQueryGenerator) BuildQuery(ctx context.Context) (string, error | |
| if err != nil { | ||
| return "", fmt.Errorf("error while converting column type to clickhouse type: %w", err) | ||
| } | ||
| } else if (schema.NullableEnabled || columnNullableEnabled) && column.Nullable && !colType.IsArray() && | ||
| !strings.HasPrefix(clickHouseType, "Nullable(") { | ||
| // mirror the table DDL: a nullable-enabled column created as Nullable(...) must also be | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we move it to the helper then?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's the same condition today but JSON extraction function and DDL are different enough IMO as to maybe make us stumble upon different conditions in future changes. |
||
| // extracted as Nullable(...), or JSON nulls turn into the type's default value | ||
| clickHouseType = fmt.Sprintf("Nullable(%s)", clickHouseType) | ||
| } | ||
|
|
||
| switch clickHouseType { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
afaiu tableSchema.NullableEnabled is kind of a global flag whether we want to have nullable fields at the destination at all (regardless of source column nullability)
so, I think it should be
tableSchema.NullableEnabled && columnNullableEnabled, no?if tableSchema.NullableEnabled is false, it means that none of the destination columns can be nullable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah
we have schema.NullableEnabled and column.NullableEnabled
seems like we can put false on the schema lvl and override on the column lvl..
so
ORis correct here I guessThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, at least this is how I interpret it.