【问题标题】:Get field from unstructured array in Prestodb从 Prestodb 中的非结构化数组中获取字段
【发布时间】:2021-02-02 16:23:30
【问题描述】:

我正在尝试在 presto db 源中查询数组中的类别和类别 ID (cat_id),如下所示。 我对其他列使用了查询“json_extract_scalar”(data.reason,'$ [0].column')并且它有效,但它不适用于这些数组,因为这个级别是非结构化的,不是json,它是数组格式.
有人有什么建议吗?我抓不到[catid],我尝试了很多解决方案。

【问题讨论】:

  • 能否把图片换成纯文本
  • Tks,在这里工作过。

标签: arraylist presto trino


【解决方案1】:

它的工作原理如下,使用选择和级别之间的航行:

-- [data] 是我的数组列

SELECT data[1][4]  as tester, 
data[1][4][2]   as tester4,
data[1][4][3]   as tester5  
from MyTable

【讨论】:

    猜你喜欢
    • 2021-04-03
    • 1970-01-01
    • 2013-03-19
    • 1970-01-01
    • 2021-05-15
    • 2016-05-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多