From the ClickHouse Docs:
The expression expr is optional. If it is omitted, the column type must be specified explicitly and the default value will be 0 for numeric columns, '' (the empty string) for string columns, [] (the empty array) for array columns, 1970-01-01 for date columns, or NULL for nullable columns.
Currently the binary driver refuses to insert a NULL into a non-Nullable column, but the http driver allows it. Add tests with explicit DEFAULT values on the ClickHouse tables and ensure that the http driver does the right thing when inserting a NULL (with and without a corresponding constraint on the foreign Postgres table).
Determine whether the binary driver behavior should be the same, and if so remove this block and fix issues accordingly:
|
/* |
|
* Prevent insertion if the column isn't Nullable. This differs from the |
|
* http engine, which isn't aware of Nullable but just sends values off, |
|
* in which case ClickHouse inserts default values (e.g., 0 for numbers, |
|
* "" for strings, etc.). |
|
* |
|
* XXX Do we want to consider rejecting NULL inserts when the Postgres |
|
* `NOT NULL` constraint exits? And when it doesn't exist and the column |
|
* is not nullable, do we want to send the default value instead? Dropping |
|
* this block should do that. |
|
*/ |
|
if (isnull && !nullable) |
|
throw std::runtime_error( |
|
"cannot append NULL to NOT NULL " + col->Type()->GetName() + " column" |
|
); |
From the ClickHouse Docs:
Currently the binary driver refuses to insert a NULL into a non-
Nullablecolumn, but the http driver allows it. Add tests with explicitDEFAULTvalues on the ClickHouse tables and ensure that the http driver does the right thing when inserting aNULL(with and without a corresponding constraint on the foreign Postgres table).Determine whether the binary driver behavior should be the same, and if so remove this block and fix issues accordingly:
pg_clickhouse/src/binary.cpp
Lines 429 to 443 in a9f4fc0