yandex - Couldn't parse csv file if value contains from '
问题描述
Here is demo DDL:
CREATE TABLE X (
eventdate Date default toDate(now()),
f1 String,
f2 String,
f3 String
) ENGINE = MergeTree(eventdate, (f1, f2, f3), 8192)
When I try to import data, clickhous fails with error:
$echo "US,'Ewa Beach, Test" | clickhouse-client --database default --query "insert into X(f1, f2, f3) format CSV"
Code: 27. DB::Exception: Cannot parse input: expected , at end of
stream.: (at row 1)
Here is my click house version(it time of writing it's latest version, if I am not mistaking):
$ clickhouse-client --version
ClickHouse client version 1.1.54385.
The problem is ' symbol in the value of field f2. Please, any workaround to make it works?
Maybe is there some option to force using a only double quote as a string delimiter, and consider single quote as plain symbol without special meaning? Please, any solution is welcome.
I just tested with same values but as tsv, and it works. But unfortunately I cannot migrate to tsv right now. I need to find out some workaround for csv to make it work with signle quote in field value.
P.S.
Interesting that if left only two fields, it parses csv correctly.
CREATE TABLE X (
eventdate Date default toDate(now()),
f1 String,
f2 String
) ENGINE = MergeTree(eventdate, (f1, f2), 8192)
The following query workds:
$echo "US,'Ewa Beach" | clickhouse-client --database default --query "insert into X(f1, f2) format CSV"
Here is related issue on the GitHub
解决方案
我刚刚遇到了同样的问题。我创建了一个 PR https://github.com/yandex/ClickHouse/pull/2574
有了它,您可以指定使用format_allow_csv_single_quote=0
以 a 开头的字符串字段解析 csv 数据'
编辑:
现在已经合并了。
推荐阅读
- testing - 用户角色:纱线开始 = 通过,纱线构建 = 失败
- java - Maven编译报错:包不存在,找不到符号
- flutter - 获取正确的时间,因为应用程序在没有网络的情况下关闭
- python - pandas cumsum 将 cumsum 计算的结果替换为指定位置的内容
- c# - 如何在C#中的一个字符的句子中将十进制转换为整数?
- r - 为什么 geom_line 中间的 NA 并不总是断线?
- ms-word - 使用 Word Api 从内容控件中检索数据
- mysql - http 错误 404.0 - 在 xampp 服务器中找不到
- xcode - 以下文件超过 100mb。- Github
- reactjs - 反应印第安纳州滚动 - 初始滚动不起作用