【问题标题】:INSERT using CSV file with single quote in string field cause error在字符串字段中使用带有单引号的 CSV 文件插入会导致错误
【发布时间】:2020-09-24 18:30:17
【问题描述】:

在字符串字段中使用带有单引号的 CSV 文件插入会导致此类情况出现错误

"'Catbug' Animated Series In The Works From 'Adventure Time ..."

但其他使用单引号的场景加载成功。这个问题有解决办法吗?

【问题讨论】:

    标签: clickhouse


    【解决方案1】:

    通过使用format_csv_allow_single_quotes-参数禁止将单引号解释为分隔符:

    echo "'Catbug' Animated Series In The Works From 'Adventure Time ..." |
        clickhouse-client --query "insert into test format CSV" --format_csv_allow_single_quotes 0
    
    echo "'Catbug' Animated Series In The Works From 'Adventure Time ..." |
        clickhouse-client --query "insert into test format CSV settings format_csv_allow_single_quotes=0"
    

    【讨论】:

    • 谢谢,我使用了第二个示例,因为我调用 POST 方法来执行 INSERT。我注意到添加标志后 INSERT 变慢了。但它解除了我前进的阻碍。
    【解决方案2】:

    clickhouse-client --format_csv_allow_single_quotes=0

    这是因为 CH 使用第一个字符 ' 或 " 自动发现使用过的引号

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-24
      • 1970-01-01
      • 1970-01-01
      • 2022-11-16
      • 2015-09-16
      • 1970-01-01
      • 1970-01-01
      • 2021-05-11
      相关资源
      最近更新 更多