Skip to content

Tracking: jsonb operations #7714

Closed
Closed
@xiangjinwu

Description

@xiangjinwu

Listing all jsonb operations from PostgreSQL, and which ones to implement now, soon, or until requested.

Basic

  • TEXT format input / output (same as cast from / to string)
  • BINARY format input / output

General for all types:

  • IS [NOT] NULL / CASE WHEN / COALESCE / etc

Eq / Hash / Ord

  • There is no plan to support this type of operations right now.
  • Also includes IS [NOT] DISTINCT / NULLIF / IN / etc

Cast to simple types

  • bool
  • smallint / int / bigint / decimal / real / double precision
  • There is no cast from them to jsonb, but a function to_jsonb.

Accessing array / object

Informative / Debugging

Predicate

Construction / Mutation

Subscripting

  • Avoid j[index] / j[key] and use #> / #>> / -> / ->> instead.

Aggregation

Table Function (aka Set Returning Function)

Advanced

jsonpath type

Additional Details

While SQL array is 1-indexed, JSON array as part of SQL is still 0-indexed.

Our goal is to ingest JSON data and then extract strongly-typed columns from it. So operations on constructing / mutating / comparison of JSON are not of interest right now.

Dedicated string member access operator vs Cast to string

with t(v1) as (values (null::jsonb), ('null'), ('true'), ('1'), ('"a"'), ('[]'), ('{}')),
     j(v1) as (select ('{"k":' || v1::varchar || '}')::jsonb from t)
select
    v1 ->> 'k',
    (v1 -> 'k')::varchar,
    jsonb_typeof(v1 -> 'k')
from j order by 2;
----
a "a" string
1 1 number
[] [] array
NULL null null
true true boolean
{} {} object
NULL NULL NULL

Operations on object keys also work for array string elements
(TODO)

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions