duckdb / postgres_scanner

https://duckdb.org/docs/extensions/postgres
MIT License
230 stars 37 forks source link

Filtering by char column doesn't work correctly in Postgres_scanner #68

Closed osawyerr closed 1 year ago

osawyerr commented 1 year ago

What happens?

When filtering by a char column the query doesn't return correct results if the filter is not pushed down to Postgres. For example in the customer table of TPC-H, the c_mktsegment is usually a char(10).

select count(*), c_mktsegment from customer where c_mktsegment = 'BUILDING' group by c_mktsegment;

doesn't return any results when the filter is not pushed down to Postgres. However when the filter is pushed down to Postgres, the query returns the correct result. I believe its because Postgres ignores the blank space padding of the column but duckdb does not.

Similarly, if the query is written explicitly with the blank spaces padding, and the filter isn't pushed down, then this also works OK.

select count(*), c_mktsegment from customer where c_mktsegment = 'BUILDING ' group by c_mktsegment;

To Reproduce

CALL postgres_attach('host=localhost port=28815 dbname=tpch', source_schema='tpch', filter_pushdown=false, overwrite=true);

OS:

MacOS

PostgreSQL Version:

15

DuckDB Version:

0.6.1

DuckDB Client:

CLI

Full Name:

Olo Sawyerr

Affiliation:

None. Hobby projects.

Have you tried this on the latest master branch?

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

Mytherin commented 1 year ago

Thanks for the report! This should be fixed now in #111.