【问题标题】:SnowSQL JSONL vs JSONSnowSQL JSONL 与 JSON
【发布时间】:2021-03-31 12:42:32
【问题描述】:

是否可以使用 JSON file format type='JSON' 加载 JSONL?还是我需要将 JSONL 转换为 JSON?

就目前而言,我可以暂存数据,但是当我尝试将数据复制到表中时,查询错误提示存在数据错误。

【问题讨论】:

    标签: snowflake-cloud-data-platform


    【解决方案1】:

    您可以使用 CSV 格式读取 JSONL 的每一行(带有非通用分隔符),然后使用 PARSE_JSON 对其进行解析。

    示例 test.jsonl:

    { "id":1, "name":"Gokhan"}
    { "id":2, "name":"Jack"}
    { "id":3, "name":"Joe"}
    

    示例文件格式对象:

    create file format jsonl type=CSV field_delimiter = '*xyz*';
    

    使用 parse_json 读取:

    select parse_json($1) js, js:id, js:name from @my_stage (file_format=>jsonl);
    

    【讨论】:

    • 出于某种原因,我仍然不得不使用文件格式 json,因为 json 文档中有特殊字符会触发错误。例如,在文档中找到了//,它正在挂起表格插入过程。
    猜你喜欢
    • 1970-01-01
    • 2016-12-19
    • 2021-08-21
    • 1970-01-01
    • 1970-01-01
    • 2018-11-01
    • 2019-12-13
    • 2019-01-17
    • 2021-03-28
    相关资源
    最近更新 更多