我的 AWS QLDB 表中有下表:
INSERT INTO Testing << {
'MyId': 1,
'MyList': [ 'Item1', 'Item2', 'Item3']
},
{
'MyId': 2,
'MyList': [ 'Item2', 'Item3', 'Item4']
},
{
'MyId': 3,
'MyList': [ 'Item4', 'Item5', 'Item6']
}
>>
我需要能够获取包含项目列表(不是来自另一个表)的所有文档,我正在使用以下查询:
SELECT *
FROM Testing AS t,
t.MyList AS l
WHERE l IN ('Item1', 'Item2', 'Item4')
但是,这给出了以下输出
+------+---------------------------+---------+
| MyId | MyList | _3 |
+------+---------------------------+---------+
| 3 | ["Item4","Item5","Item6"] | "Item4" |
+------+---------------------------+---------+
| 1 | ["Item1","Item2","Item3"] | "Item1" |
+------+---------------------------+---------+
| 1 | ["Item1","Item2","Item3"] | "Item2" |
+------+---------------------------+---------+
| 2 | ["Item2","Item3","Item4"] | "Item2" |
+------+---------------------------+---------+
| 2 | ["Item2","Item3","Item4"] | "Item4" |
+------+---------------------------+---------+
我希望能够得到三个不同的行。它会根据我在尝试使用DISTINCT
QLDB 不支持它时遇到的错误出现,但我也更喜欢*
在我的中使用SELECT
,所以我正在尝试使用GROUP BY
SELECT *
FROM Testing AS t,
t.MyList AS l
WHERE l IN ('Item1', 'Item2', 'Item4')
GROUP BY t.MyId
但这会产生以下错误:
开始查询错误
语义错误:在行,列:没有名为'$__partiql__group_by_1_item_0'的变量;没有名为“$__partiql__group_by_1_item_0”的变量(服务:AmazonQLDBSession;状态代码:400;错误代码:BadRequestException;请求 ID:65vrQHytqHdEL3o9Ym9Xn4)