fix(DBI-1096 - clickhouse destination connector): Honor nullability for destination_type overrides in normalize - #4783
Conversation
| return nil, fmt.Errorf("error while converting column type to ClickHouse type: %w", err) | ||
| } | ||
| } else if (tableSchema.NullableEnabled || columnNullableEnabled) && column.Nullable && !colType.IsArray() { | ||
| } else if (tableSchema.NullableEnabled || columnNullableEnabled) && column.Nullable && !colType.IsArray() && |
There was a problem hiding this comment.
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.
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 OR is correct here I guess
There was a problem hiding this comment.
seems like we can put false on the schema lvl and override on the column lvl..
Exactly, at least this is how I interpret it.
| } | ||
| } 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 |
There was a problem hiding this comment.
should we move it to the helper then?
if it's exactly the same condition as in flow/connectors/clickhouse/normalize.go.
There was a problem hiding this comment.
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.
🔄 Flaky Test DetectedAnalysis: All 88 failures are timeout collateral from ✅ Automatically retrying the workflow |
With a table mapping column setting both a
destination_typeoverride and nullability (table- or column-levelnullable_enabled), the DDL generator creates the destination column as Nullable(), but the normalize query still extracted it as plain . JSONExtract to a non-nullable type turns JSON nulls into the type's default, so NULL values silently landed as0," ", etc. instead of NULL.This PR makes the normalize query generator mirror the DDL:
Part of: https://linear.app/clickhouse/issue/DBI-1096
Related to: