如何 select 来自兄弟数组的字段?

How to select field from a sibling array?

我想要 select 来自 FieldName=Field4 的元素的值 ('Value'),其中来自 FieldName=Field2 的元素的值 ('Value') 为 null。

{
    "FormName":"Form1",
    "Id": "ID1",
    "Module":{
       "ModuleType":"Form",
       "Layout":"Vertical",
       "ControlList":[
          {
             "ControlType":"Widget",
             "Layout":"Vertical",
             "FieldList":[
                {
                   "FieldType":"TextBox",
                   "FieldName":"Field1",
                   "Value":"field1"
                },
                {
                   "FieldType":"TextBox",
                   "FieldName":"Field2",
                   "Value":null
                },
                {
                   "FieldType":"TextBox",
                   "FieldName":"Field1",
                   "Value":"field3"
                }
             ]
          },
          {
             "ControlType":"Widget",
             "Layout":"Vertical",
             "FieldList":[
                {
                   "row":[
                      {
                         "FieldType":"TextBox",
                         "FieldName":"Field3",
                         "Value":"field3"
                      },
                      {
                         "FieldType":"TextBox",
                         "FieldName":"Field4",
                         "Value":"field4"
                      }
                   ]
                }
             ]
          }
       ]
    }
 }

我了解如何获得正确的数据集:

select
 form.Id
from
 `test` as form
where
 any cl in form.Module.ControlList satisfies 
   any fl in cl.FieldList satisfies fl.FieldName = 'Field2' AND fl.`Value` is null
   end 
 end;

...返回:

[
  {
    "Id": "ID1"
  }
]

但是我的 select 语句应该如何得到这个:

[
  {
    "Value": "field4"
  }
]

使用ARRAY construct

SELECT
 ARRAY_FLATTEN((ARRAY (ARRAY (ARRAY {r.`Value`}
               FOR r IN f.`row`
               WHEN r.FieldName = "Field4"
               END)
        FOR f IN c.FieldList
        END)
 FOR c IN t.Module.ControlList
 END),3)[0].*
FROM `test` AS t
WHERE (ANY cl IN t.Module.ControlList
       SATISFIES (ANY fl IN cl.FieldList
                  SATISFIES fl.FieldName = 'Field2' AND fl.`Value` IS NULL
                  END)
       END);