0

像这样结构化的数据

{
    "rows": [
        {
            "rowId": "IDP_2z8dfj9KbB1hrPI_1554508960_1_1",
            "version": "1554508960",
            "lastUpdatedDate": 1554508960604,
            "createdAt": 1554508960604,
            "payload": ""
        },
        {
            "rowId": "IDP_2z8dfj9KbB1hrPI_1554508960_1_2",
            "version": "1554508960",
            "lastUpdatedDate": 1554508960604,
            "createdAt": 1554508960604,
            "payload": ""
        },
        {
            "rowId": "IDP_2z8dfj9KbB1hrPI_1554508960_1_3",
            "version": "1554508960",
            "lastUpdatedDate": 1554508960604,
            "createdAt": 1554508960604,
            "payload": ""
        }
    ]
}

以下选择查询

select * from S3Object s where 'IDP_2z8dfj9KbB1hrPI_1554508960_1_2' in s[*]."rows"[*]."rowId"

返回整个 JSON 文档,我希望它只返回一行,即

[{
            "rowId": "IDP_2z8dfj9KbB1hrPI_1554508960_1_2",
            "version": "1554508960",
            "lastUpdatedDate": 1554508960604,
            "createdAt": 1554508960604,
            "payload": ""
}]

我已经尝试了查询的几种变体

select s.rows[0] from S3Object s where 'IDP_2z8dfj9KbB1hrPI_1554508960_1_2' in s[*]."rows"[*]."rowId"

它只返回 1 条记录,但它是错误的记录。

select * from S3Object s where  s[*]."rows"[*]."rowId"='IDP_2z8dfj9KbB1hrPI_1554508960_1_2'

什么都不返回。

关于我做错了什么的任何想法?

4

1 回答 1

1

在对查询进行了多次修改后,我能够得到我的预期结果

select * from S3Object[*]."rows"[*] as r  where ('IDP_2z8dfj9KbB1hrPI_1554508960_1_1') in r[*]."rowId"
于 2019-04-07T00:02:08.637 回答