【问题标题】:Postgres: "Cannot call json_populate_recordset on an object" ErrorPostgres:“无法在对象上调用 json_populate_recordset”错误
【发布时间】:2019-11-25 14:11:42
【问题描述】:

我有一张表,其中一列(“actionDetails”)中包含未打包的 json,有时每行包含多个 json。出于某种奇怪的原因,查询

    SELECT "idVisit" AS visit_id,
    t.* FROM dl.live_last_visits_details_pvk,
    json_populate_recordset(null::json_type, "actionDetails" :: JSON) as t

给出我想要的确切结果——直到我跳到结果的末尾,当它关闭表格并给我[22023] ERROR: cannot call json_populate_recordset on an object.

同样,如果我尝试将此查询保存到表中,我会收到同样的错误。

DROP TABLE IF EXISTS temp;
CREATE TEMP TABLE temp AS (
    SELECT "idVisit" AS visit_id,
    t.* FROM dl.live_last_visits_details_pvk,
    json_populate_recordset(null::json_type, "actionDetails" :: JSON) as t
);
SELECT * FROM temp;

有谁知道是什么原因造成的(也许是一些不是 json 的奇怪行值?),我该如何解决?不知道如何搜索可能隐藏在列值中的其他类型的对象,而且它是一个非常大的表,所以我不能只是筛选。我正在处理的数据有很多行并且经常更改,所以我需要编写可以处理这样奇怪的代码。有什么想法吗?

感谢您的宝贵时间!

【问题讨论】:

    标签: arrays json postgresql recordset


    【解决方案1】:

    我遇到了同样的错误。就我而言,当我的 live_last_visits_details_pvk 版本中有 2 行或更多行时,一切正常。当我正好有 1 行时,PostgreSQL 会发疯并抛出此错误。我(还)没有聪明的解决方案,但我希望现在能有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-03
      • 1970-01-01
      • 1970-01-01
      • 2014-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多