ildus / clickhouse_fdw

ClickHouse FDW for PostgreSQL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unknown function btrim

fantom0005 opened this issue · comments

Hi guys.

I tried to use function trim in "where" block in postgres and got the error message: "Unknown function btrim QUERY:SELECT field FROM "default".test_table WHERE ((btrim(field) <> ''))"

How to reproduce:

  1. Create table in ClickHouse
create table test_table (field String) engine = MergeTree() ORDER BY (field);
  1. Add value to table
insert into test_table values ('213');
  1. Create fdw table in postgres
create foreign table test_table ("field" text) server clickhouse_svr;
  1. Select data and use function trim in where
select * from test_table where trim(field) <> '';

I checked on versions:

  • PostgreSQL 12.3 (Debian 12.3-1.pgdg110+1+b1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 9.3.0-14) 9.3.0, 64-bit
  • ClickHouse Verion 20.5.4.40

I found workaround. But it's very strange

You can use functions ltrim, rtrim together. It works.

select * from test_table where ltrim(rtrim(field)) <> '';

It's not strange, clickhouse already has ltrim and rtrim functions, but not btrim. I haved added translation to trimBoth.