Skip to content

PostgreSQL compatibility: json_array_length does not interpret arg as json #1041

@emarsden

Description

@emarsden

What happens?

In PostgreSQL, the query select json_array_length('[]') returns 0.

In PGDuckDB, the query triggers an error function json_array_length(unknown) is not unique.

To Reproduce

pgeltestdb=# SELECT json_array_length('[]');
ERROR:  function json_array_length(unknown) is not unique
LIGNE 1 : SELECT json_array_length('[]');
                 ^
ASTUCE : Could not choose a best candidate function. You might need to add explicit type casts.

OS:

Linux

pg_duckdb Version (if built from source use commit hash):

Current Dockerhub image docker.io/pgduckdb/pgduckdb:18-main

Postgres Version (if built from source use commit hash):

PostgreSQL 18.3 (Debian 18.3-1.pgdg12+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14+deb12u1) 12.2.0, 64-bit

Hardware:

No response

Full Name:

Eric Marsden

Affiliation:

None

What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have tested with a stable release

Did you include all relevant data sets for reproducing the issue?

Yes

Did you include all code required to reproduce the issue?

  • Yes, I have

Did you include all relevant configuration (e.g., CPU architecture, Linux distribution) to reproduce the issue?

  • Yes, I have

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions