【问题标题】:Extract negative integers from JSON从 JSON 中提取负整数
【发布时间】:2020-02-08 08:14:53
【问题描述】:

我在 PrestoSQL 中使用json_extract 函数,但是,如果键值对在值中出现负整数,例如

{"foo":-12345, "bar": 12345}

json_extract(json, '$.foo') 将返回 NULL 但是

json_extract(json, '$.bar') 将返回 12345

json_extract_scalar 也产生相同的结果。

在 Presto 中提取负整数的解决方法是什么?

【问题讨论】:

    标签: sql json presto json-extract trino


    【解决方案1】:

    它在当前 master (Presto 320) 中按预期工作:

    presto:default> SELECT json_extract(JSON '{"foo":-12345, "bar": 12345}', '$.foo');
     _col0
    --------
     -12345
    (1 row)
    
    presto:default> SELECT json_extract_scalar(JSON '{"foo":-12345, "bar": 12345}', '$.foo');
     _col0
    --------
     -12345
    (1 row)
    

    【讨论】:

      猜你喜欢
      • 2017-06-29
      • 2019-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-04
      • 1970-01-01
      • 2011-08-27
      相关资源
      最近更新 更多