You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Detect UTF-16 BOM in CSV/TSV/JSONEachRow input and process it accordingly. #6476
Make UTFConvertingReadBuffer that will work as a wrapper on top of another ReadBuffer and it will check for these types of BOMs:
UTF-8 BOM
UTF-16 LE BOM
UTF-16 BE BOM
UTF-32 LE BOM
UTF-32 BE BOM
If UTF-8 BOM is found, it will be ignored (and this can replace the existing logic of ignoring the UTF-8 BOM in TSV, CSV, etc),
and the UTFConvertingReadBuffer will provide the remaining data in zero-copy fashion.
If other BOM is found, we will use it to detect the charset and convert it on the fly to UTF-8.
Care should be taken for correct processing of surrogate pairs.
It's ok to convert invalid sequences to � or to another implementation-defined invalid sequence.
The conversion should be performed without excessive buffering.
[22000] Code: 117. DB::Exception: Unknown field found in format header: '��D�a�t�e�' at position 0 Set the 'input_format_skip_unknown_fields' parameter explicitly to ignore and proceed: (while reading header):
I did something but that didn't work the way I thought it to work. I was supposed to close this but other commitments took priority and in recent times my system kind of gave up while doing dev for CH so I am blocked. If you want you can build upon my draft PR.
Activity
alexey-milovidov commentedon May 1, 2022
It can be solved in generic way.
Make
UTFConvertingReadBufferthat will work as a wrapper on top of anotherReadBufferand it will check for these types of BOMs:If UTF-8 BOM is found, it will be ignored (and this can replace the existing logic of ignoring the UTF-8 BOM in TSV, CSV, etc),
and the
UTFConvertingReadBufferwill provide the remaining data in zero-copy fashion.If other BOM is found, we will use it to detect the charset and convert it on the fly to UTF-8.
Care should be taken for correct processing of surrogate pairs.
It's ok to convert invalid sequences to � or to another implementation-defined invalid sequence.
The conversion should be performed without excessive buffering.
mrdimidium commentedon Jun 24, 2024
Hi, @alexey-milovidov! Is it still relevant? I'd like to try it.
alexey-milovidov commentedon Jun 24, 2024
@nikolay-govorov, yes, it is relevant, and it will be very appreciated!
chrisgoddard commentedon Feb 6, 2025
Any update on this?
alexey-milovidov commentedon Feb 6, 2025
@chrisgoddard, no update on this - no one took this task.
hp77-creator commentedon Oct 23, 2025
Hi @alexey-milovidov, I am picking this one, will try to share a PR before end of month
alexey-milovidov commentedon Oct 23, 2025
@hp77-creator, thank you for this!
StashOfCode commentedon May 15, 2026
@hp77-creator, @alexey-milovidov how is it going? csv file in a gcs bucket is interpreted as garbage by clickhouse:
[22000] Code: 117. DB::Exception: Unknown field found in format header: '��D�a�t�e�' at position 0 Set the 'input_format_skip_unknown_fields' parameter explicitly to ignore and proceed: (while reading header):
when 'ContentType': 'text/csv; charset=utf-16le',
hp77-creator commentedon May 15, 2026
I did something but that didn't work the way I thought it to work. I was supposed to close this but other commitments took priority and in recent times my system kind of gave up while doing dev for CH so I am blocked. If you want you can build upon my draft PR.
StashOfCode commentedon May 15, 2026
@hp77-creator thanks for the effort, regardless. My c++ skills are nonexistent otherwise, I would have tried.