Skip to content

Fix or prevent NULLs in binary driver#145

Merged
theory merged 1 commit intomainfrom
uuid-null
Feb 4, 2026
Merged

Fix or prevent NULLs in binary driver#145
theory merged 1 commit intomainfrom
uuid-null

Conversation

@theory
Copy link
Collaborator

@theory theory commented Feb 3, 2026

Allow Nullable(x) to work in the binary driver for Numeric, Text, UUID, and INET columns. Add tests for all other currently supported columns. Raise exceptions for Enums, which cannot currently be NULL (but there should be a way to allow it like the http driver), as well as LowCardinality(Nullable(x)), which is allowed but currently unreachable.

It's unreachable because the binary driver currently does not allow NULLs unless the column is explicitly Nullable() and Nullable(LowCardinality(x)) is not supported by ClickHouse.

But leave the exception, because we may want to eliminate that constraint and let NULLs go through, as ClickHouse will treat them as defaults. For example NULL for Int8 becomes 0, for IPv6 becomes ::. This is the behavior of the http driver, but we may want to remove it there, too, at least when the Postgres column has a NOT NULL constraint. Leave a long comment explaining this state of affairs

While at it, improve the error message from that block, as it was confusing before.

Add tests for all of the data types currently supported by the binary driver to both the binary and the http driver insertion tests. In the latter case, NULL enums work properly, and as explained above, default values are replaced for NULLs. The tests also verify array behavior, which currently disallows nested arrays. Sadly, ARRAY[NULL] fails on ClickHouse 23, so we need another expected output file.

Fixes #140.

@theory theory requested a review from serprex February 3, 2026 22:04
@theory theory self-assigned this Feb 3, 2026
@theory theory added bug Something isn't working data types Improve data type support engines Improve binary and/or http engine support labels Feb 3, 2026
Allow `Nullable(x)` to work in the binary driver for Numeric, Text,
`UUID`, and `INET` columns. Add tests for all other currently supported
columns. Raise exceptions for Enums, which cannot currently be `NULL`
(but there should be a way to allow it like the http driver), as well as
`LowCardinality(Nullable(x))`, which is allowed but currently
unreachable.

It's unreachable because the binary driver currently does not allow
`NULL`s unless the column is explicitly `Nullable()` and
`Nullable(LowCardinality(x))` is not supported by ClickHouse.

But leave the exception, because we may want to eliminate that
constraint and let `NULL`s go through, as ClickHouse will treat them as
defaults. For example `NULL` for `Int8` becomes `0`, for `IPv6` becomes
`::`. This is the behavior of the http driver, but we may want to remove
it there, too, at least when the Postgres column has a `NOT NULL`
constraint. Leave a long comment explaining this state of affairs

While at it, improve the error message from that block, as it was
confusing before.

Add tests for all of the data types currently supported by the binary
driver to both the binary and the http driver insertion tests. In the
latter case, `NULL` enums work properly, and as explained above, default
values are replaced for `NULL`s. The tests also verify array behavior,
which currently disallows nested arrays. Sadly, `ARRAY[NULL]` fails on
ClickHouse 23, so we need another expected output file.
@theory theory merged commit a9f4fc0 into main Feb 4, 2026
47 of 49 checks passed
@theory theory deleted the uuid-null branch February 4, 2026 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working data types Improve data type support engines Improve binary and/or http engine support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Connection Terminates Unexpectedly When Using NULL Value for UUID

2 participants