| From: | "daidewei1970(at)163(dot)com" <daidewei1970(at)163(dot)com> |
|---|---|
| To: | 河田達也 <kawatatatsuya0913(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [Proposal] Adding TRIM_SPACE option to COPY |
| Date: | 2025-11-25 04:51:54 |
| Message-ID: | 202511251251504038821@163.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
HI,
This change seems very useful, I participated in a related project before. After reviewing the patch,
I have a suggestion, would it be better to restrict the change to only "copy from"?
daidewei1970(at)163(dot)com
From: 河田達也
Date: 2025-11-25 00:17
To: pgsql-hackers
Subject: [Proposal] Adding TRIM_SPACE option to COPY
Hi,
I'd like to propose adding a new option, TRIM_SPACE, to the COPY command.
Other data warehouse systems such as Snowflake provide similar functionality
(TRIM_SPACE) to improve robustness when loading CSV data. PostgreSQL does not currently have
such an option, although it would be consistent with other user-friendly
features already present in COPY (e.g., FORCE_NULL, FORCE_NOT_NULL, ON_ERROR).
Proposed feature
----------------
Add a boolean option:
TRIM_SPACE = true | false
(default: false)
When enabled, COPY FROM with FORMAT text or csv will trim leading and trailing
ASCII whitespace from each column value before NULL processing and type
conversion. This is applied only to FORMAT text and csv.(not binary)
Example usage:
COPY mytable
FROM '/tmp/data.csv'
WITH (FORMAT csv, HEADER true, TRIM_SPACE true);
This would transform(trim leading and trailing ASCII whitespace):
" AAA ", " BBB", "CCC "
into:
'AAA', 'BBB', 'CCC'
----------------
Thanks in advance for your comments.
Best regards,
Tatsuya Kawata
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Fujii Masao | 2025-11-25 04:54:45 | Re: [Proposal] Adding TRIM_SPACE option to COPY |
| Previous Message | Dilip Kumar | 2025-11-25 04:50:01 | Re: Patch: dumping tables data in multiple chunks in pg_dump |