小编Bra*_*don的帖子

Postgres:什么可能导致错误“无法在标量上调用 populate_composite”?

我有一列 type JSONB,其中每一行都包含一个带有对象数组的 JSON,例如:

[
    {
        "grade": "4.44/5",
        "endYear": 2011,
        "startYear": 2006,
        "userId": "defg"
    },
    {
        "grade": "9.133/10",
        "endYear": 2010,
        "startYear": 2006,
        "userId": "abcd"
    }
]
Run Code Online (Sandbox Code Playgroud)

我正在尝试将这些JSONB集合扩展为行,例如:

| grade    | startYear | endYear | userId |
-------------------------------------------
| 4.44/5   |    2006   | 2011    | defg   |
| 9.133/10 |    2006   | 2010    | abcd   |
-------------------------------------------
Run Code Online (Sandbox Code Playgroud)

..使用以下查询:

WITH arr AS (SELECT jsonb_array_elements(jsonbrecords) AS jsons
             FROM "table-with-jsonb"),
    lines AS (
      SELECT x.*
      FROM arr, jsonb_to_record(jsons) AS x(
                "field1" …
Run Code Online (Sandbox Code Playgroud)

postgresql postgresql-10

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

postgresql ×1

postgresql-10 ×1