sql - 从 JSON 中提取负整数
问题描述
我json_extract
在 PrestoSQL 中使用该函数,但是,如果键值对在值中出现负整数,例如
{"foo":-12345, "bar": 12345}
json_extract(json, '$.foo')
将返回 NULL 但
json_extract(json, '$.bar')
将返回 12345
json_extract_scalar
也产生相同的结果。
在 Presto 中提取负整数的解决方法是什么?
解决方案
它在当前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)
推荐阅读
- python - 如何使 tkinter Entry 小部件中的文本保持在小部件的右侧而不是左侧?
- python - Python:计算不同csv文件中对应位置的数量之和
- php - docker php:7.4-apache 容器,无法在 localhost 中拉起页面
- python-3.x - 在 Django 地址模块中,如何通过非主键的相关实体列搜索实体?
- html - Chrome 网络开发者工具更改屏幕分辨率
- javascript - 除了我想先将其作为 lodash 模板处理之外,如何获得文件加载器的功能
- django - 如何用heroku托管静态文件,给我一个错误
- ruby-on-rails - 找不到没有身份证的假期
- react-native - 当用户按下回车键时,如何在 TextInput 上触发函数?
- google-colaboratory - 我的代码有什么问题,我尝试了很多方法,但我不断得到这个: TypeError: must be str, not int