public inbox for [email protected]
help / color / mirror / Atom feedFrom: Haibo Yan <[email protected]>
To: Andy Fan <[email protected]>
Cc: Dmitry Dolgov <[email protected]>
Cc: David Rowley <[email protected]>
Cc: Peter Eisentraut <[email protected]>
Cc: Amit Langote <[email protected]>
Cc: Alvaro Herrera <[email protected]>
Cc: jian he <[email protected]>
Cc: Chapman Flack <[email protected]>
Cc: [email protected]
Subject: Re: Extract numeric filed in JSONB more effectively
Date: Tue, 7 Apr 2026 18:21:45 -0700
Message-ID: <CABXr29HN04CqHBGZ_k6_jQmCL5FO59tDE4PUL9U56Rpu=d4=0A@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<CAApHDvqnUONCN54dAXdH678ELK7aH2gyVhh0GjTRtrexPd9YMw@mail.gmail.com>
<[email protected]>
<mmilfltxeqgajpi4zok2v2moudot6bhdmwsqgjgnymz3nvkvng@k3caignaldcp>
<[email protected]>
<cudr6wao4hz2otlycx2z2equkigbjxslxvzqb3ejfc4amroheo@frqbvffcgqnu>
<[email protected]>
<[email protected]>
<CABXr29GhnWxrGXD2YijYSDxwObGLqOsf8gvfzrFu=UcYU71XYA@mail.gmail.com>
<[email protected]>
On Tue, Apr 7, 2026 at 5:00 PM Andy Fan <[email protected]> wrote:
> Haibo Yan <[email protected]> writes:
>
> Hi Haibo,
>
> > I agree that if this approach is extended to the full matrix naively,
> > duplication will become a real issue.
>
> Could you summary how it would be? I think it would be helpful for
> others to review. Otherwise every reviewer needs to count them many
> times.
>
> --
> Best Regards
> Andy Fan
>
Hi Andy,
Sure.
My current thought is to extend it in stages, rather than trying to solve
the full matrix in a single patch.
A rough plan would be:
1. Keep the current stage-1 patch small and validate the basic approach
first
-
jsonb_object_field / -> / equivalent subscripting form
-
casts to numeric and bool
-
support-function rewrite directly to explicit typed extractor functions
2. Extend target types before extending extractor families
-
add int4 / int8 / float8 for the same object-field family first
-
keep the SQL-visible rewrite targets explicit, e.g.
-
jsonb_object_field_int4
-
jsonb_object_field_int8
-
jsonb_object_field_float8
-
avoid the previous numeric-intermediate rewrite shape
3. Then extend to other extractor families with the same overall pattern
-
likely starting with jsonb_array_element and jsonb_extract_path
-
and possibly jsonb_path_query_first later
-
each family would still rewrite to explicit typed extractor entry
points, e.g.
-
jsonb_array_element_numeric
-
jsonb_extract_path_bool
-
jsonb_path_query_first_int4
4. Keep duplication manageable by sharing the implementation underneath
-
keep the SQL/catalog-level rewrite targets explicit for readability and
reviewability
-
but factor the C implementation into:
-
extractor-family lookup helpers
-
target-type conversion helpers
-
thin wrappers, possibly generated with small macros
So the idea would be: explicit rewrite targets at the SQL/catalog level,
but shared lookup/conversion code underneath, instead of going back to the
earlier start/finish/internal pipeline.
I agree that if this is extended naively across the full matrix,
duplication will become a real issue. My reason for keeping the current
patch narrow is that I wanted to first validate this simpler rewrite shape
on a small subset before deciding how best to scale it further.
Regards,
Haibo
view thread (28+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: Extract numeric filed in JSONB more effectively
In-Reply-To: <CABXr29HN04CqHBGZ_k6_jQmCL5FO59tDE4PUL9U56Rpu=d4=0A@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox