PostgreSQL JSON_TABLE - Syntax error near COLUMNS
10:46 12 Apr 2023

Has anyone been able to get the new PostgreSQL feature for JSON_TABLE() to work? I have used it with another database and was excited to learn that PostgreSQL was to be implementing it with version 15.

We have installed version 15.2, and based on the simple example I found at https://www.depesz.com/2022/04/06/waiting-for-postgresql-15-json_table/

Where I tried the example:

select * from json_table(
    '[{"a":10,"b":20},{"a":30,"b":40}]'::jsonb,
    '$[*]'
    COLUMNS (
        column_a int4 path '$.a',
        column_b int4 path '$.b'
    )
);

However, I get a response of "SQL Error [42601]: ERROR: syntax error at or near "COLUMNS""

Is there a typo in the example? I've only found a couple of examples. All give the same error.

postgresql