Open nsscan opened 6 years ago
Good catch... It's actually a bug in the underlying infi.clickhouse_orm module. It ignores zero-length lines when parsing the results from ClickHouse. So if you select only a single string column, and the column has no value, you get back an empty line (which is ignored). If you select two columns, there's a tab character between their values so the line is no longer empty.
A foreign table in postgresql does not receive the full query result set from clickhouse when there are rows consisting of the empty string.
example table configured in clickhouse
Querying this table to select all the 'd' values
This table is also configures in PostgreSQL as a foreign table
but now the same select returns an incomplete result set when run in PostgreSQL
The expected results are 3 rows, 2 with empty strings and 1 with value '1' - i.e. the same results as clickhouse returns.
only if we add the key column is the correct number of rows returned
The Foreign Data Wrapper seems to be incorrectly translating and executing the query or incorrectly retrieving the result set from clickhouse by filtering result rows which are entirely empty strings.
The problem is identical is we use the other columns, 'c' or 'a'
select c is worse as it returns 0 rows rather than 3 rows with empty strings.
If a 2nd column is added, the issue seems to go away