Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostgreSQL EXTRACT Function based on Clickhouse table doesn't work in ORDER BY clause #98

Open
mixavich opened this issue Mar 5, 2023 · 0 comments

Comments

@mixavich
Copy link

mixavich commented Mar 5, 2023

A simple query
SELECT "InsertionDate" from "AdvertisingCab" order by extract(YEAR from "InsertionDate"), extract (MONTH from "InsertionDate");
, where AdvertisingCab is a PostgreSQL view linked to a similar Clickhouse table, falls with the following error:

ERROR: clickhouse_fdw:Code: 43. DB::Exception: Illegal type DateTime('UTC') of argument of function extract: While processing extract('year', insertion_date) ASC, extract('month', insertion_date) ASC. (ILLEGAL_TYPE_OF_ARGUMENT)
QUERY:SELECT "insertion_date" FROM "test".advertising_cabinet ORDER BY extract('year', "insertion_date") ASC, extract('month', "insertion_date") ASC

In other words, clickhouse_fdw translates the extract functions in the order by clause incorrectly.

At the same time the query
SELECT extract(YEAR from "InsertionDate"), extract (MONTH from "InsertionDate") from "AdvertisingCab"
translates into

QUERY PLAN

Foreign Scan on public.advertising_cabinet (cost=0.00..0.00 rows=0 width=64)
Output: EXTRACT(year FROM advertising_cabinet."insertion_date"), EXTRACT(month FROM advertising_cabinet."insertion_date")
Remote SQL: SELECT "insertion_date" FROM "test".advertising_cabinet
(3 rows)

and works perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant