ClickHouse / ClickHouse/pg_clickhouse
Test and if necessary repair issues inserting `NULL` to get a default value when a column has an explicit `DEFAULT`
- Dominant language
- C
- Stars
- 283
- Forks
- 21
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 11
Description
From the [ClickHouse Docs](https://clickhouse.com/docs/sql-reference/statements/create/table#default_values):
> 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:
https://github.com/ClickHouse/pg_clickhouse/blob/a9f4fc06667764368c6696231865165f977cdbf8/src/binary.cpp#L429-L443
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the NULL-handling block in src/binary.cpp at lines 429-443 and inspect the existing HTTP and binary driver tests and ClickHouse table definitions. Add cases using explicit DEFAULT values, including foreign PostgreSQL tables with and without constraints, then verify the drivers' NULL behavior and determine whether both should match.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, postgresql, sql
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100