我有一个查询的数据,如下所示:
SELECT
model_features
FROM some_db
返回:
{
"food1": 0.65892159938812,
"food2": 0.90786880254745,
"food3": 0.88357985019684,
"food4": 0.99999821186066,
"food5": 0.99237471818924,
"food6": 0.62127977609634
}
{
"food4": 0.9999965429306,
"text1": 0.82206630706787
}
...
等。
我最终要做的是简单地计算每个"food1"、"food2"功能, 但要做到这一点(我认为(,我需要修剪掉不必要的数字数据。我不知道该怎么做,因为每次我尝试简单地取消嵌套时
SELECT
t.concepts
FROM some_db
CROSS JOIN UNNEST(model_features) AS t(concepts)
我收到此错误:
Column alias list has 1 entries but 't' has 2 columns available
有人介意为我指出正确的方向吗?
为自己解决了这个问题:问题是我需要避免删除第二列信息才能执行查询。这可能不是规范的最佳方法,但它奏效了:
SELECT
t.concepts,
t.probabilities
FROM some_db
CROSS JOIN UNNEST(model_features) AS t(concepts,probabilities)