-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Since 54342bb, pg_clickhouse has been using quote_identifier() for all tables and columns imported from ClickHouse. This is kind of a pain for mixed case identifiers, because ClickHouse identifiers are case-sensitive, so require no quoting. But mixed case identifiers require quoting in Postgres.
Design an interface to allow lowercase (and therefore unquoted) identifiers to map to mixed case (or uppercase) identifiers in ClickHouse. Perhaps allow a "column_name" attribute, something like:
Foreign table "public.hits"
Column | Type | Collation | Nullable | Default | FDW options
-----------------------+-----------------------------+-----------+----------+---------+----------------------------
watchid | bigint | | not null | | (column_name 'WatchID')
javaenable | smallint | | not null | | (column_name 'JavaEnable')
title | text | | not null | | (column_name 'Title')
goodevent | smallint | | not null | | (column_name 'GoodEvent')
This would complement the foreign table table_name option, and allow lowercase column names in Postgres to map to mixed-case names in ClickHouse. The deparser would need to read these names and use them in preference to the names provided by Postgres when constructing queries.
Perhaps there could also be an option for IMPORT FOREIGN SCHEMA to tell the importer to prefer lowercase names and only fall back on quoting if there is a conflict with an earlier name.