On Sun, Feb 7, 2021 at 11:39 AM Pavel Stehule
wrote:
>
>
> ne 7. 2. 2021 v 19:18 odesílatel Zhihong Yu napsal:
>
>> Hi,
>>
>> bq. SELECT unnest('[[5,2],"a",[8,[3,2],6]]'::jsonb);
>>
>> Since the array without cast is not normal array (and would be rejected),
>> I wonder if the cast is needed.
>>
ne 7. 2. 2021 v 19:18 odesílatel Zhihong Yu napsal:
> Hi,
>
> bq. SELECT unnest('[[5,2],"a",[8,[3,2],6]]'::jsonb);
>
> Since the array without cast is not normal array (and would be rejected),
> I wonder if the cast is needed.
> Because casting to jsonb is the only legitimate interpretation here.
Hi,
bq. SELECT unnest('[[5,2],"a",[8,[3,2],6]]'::jsonb);
Since the array without cast is not normal array (and would be rejected), I
wonder if the cast is needed.
Because casting to jsonb is the only legitimate interpretation here.
Cheers
On Sun, Feb 7, 2021 at 9:42 AM Joel Jacobson wrote:
>
ne 7. 2. 2021 v 18:43 odesílatel Joel Jacobson napsal:
> On Sun, Feb 7, 2021, at 18:33, Zhihong Yu wrote:
> >Hi,
> ># SELECT '[[5,2],"a",[8,[3,2],6]]'::jsonb;
> > jsonb
> >---
> > [[5, 2], "a", [8, [3, 2], 6]]
> >(1 row)
> >
> >unnest(array[[3,2],"a",[1,4]]
On Sun, Feb 7, 2021, at 18:42, Joel Jacobson wrote:
>SELECT pit.jsonb_array_elements_recursive(value);
Sorry, that line should have been:
SELECT unnest(value);
On Sun, Feb 7, 2021, at 18:33, Zhihong Yu wrote:
>Hi,
># SELECT '[[5,2],"a",[8,[3,2],6]]'::jsonb;
> jsonb
>---
> [[5, 2], "a", [8, [3, 2], 6]]
>(1 row)
>
>unnest(array[[3,2],"a",[1,4]]) is not accepted currently.
>
>Would the enhanced unnest accept the above
On Sunday, February 7, 2021, Zhihong Yu wrote:
> Hi,
> # SELECT '[[5,2],"a",[8,[3,2],6]]'::jsonb;
> jsonb
> ---
> [[5, 2], "a", [8, [3, 2], 6]]
> (1 row)
>
> unnest(array[[3,2],"a",[1,4]]) is not accepted currently.
>
> Would the enhanced unnest accept th
Hi
ne 7. 2. 2021 v 18:31 odesílatel Zhihong Yu napsal:
> Hi,
> # SELECT '[[5,2],"a",[8,[3,2],6]]'::jsonb;
> jsonb
> ---
> [[5, 2], "a", [8, [3, 2], 6]]
> (1 row)
>
> unnest(array[[3,2],"a",[1,4]]) is not accepted currently.
>
> Would the enhanced unnest
Hi,
# SELECT '[[5,2],"a",[8,[3,2],6]]'::jsonb;
jsonb
---
[[5, 2], "a", [8, [3, 2], 6]]
(1 row)
unnest(array[[3,2],"a",[1,4]]) is not accepted currently.
Would the enhanced unnest accept the above array ?
Cheers
On Sun, Feb 7, 2021 at 8:31 AM Joel Jacobs
On Sun, Feb 7, 2021, at 17:27, Tom Lane wrote:
>"Joel Jacobson" writes:
>> Having thought about this some more,
>> the function name should of course be jsonb_unnest(),
>> similar to how unnest() works for normal arrays:
>
>Why not just unnest(), then?
>
>regards, tom lane
Ahh, of course! I total
On Sun, Feb 7, 2021, at 17:08, Pavel Stehule wrote:
>>ne 7. 2. 2021 v 16:59 odesílatel Joel Jacobson napsal:
>>
>>SELECT jsonb_unnest('[[3,2],[1,4]]'::jsonb);
>>jsonb_unnest
>>
>>3
>>2
>>1
>>4
>>(4 rows)
>
>It has sense. Maybe it should return two columns - first path to valu
"Joel Jacobson" writes:
> Having thought about this some more,
> the function name should of course be jsonb_unnest(),
> similar to how unnest() works for normal arrays:
Why not just unnest(), then?
regards, tom lane
Hi
ne 7. 2. 2021 v 16:59 odesílatel Joel Jacobson napsal:
> Having thought about this some more,
> the function name should of course be jsonb_unnest(),
> similar to how unnest() works for normal arrays:
>
> SELECT unnest(array[[3,2],[1,4]]);
> unnest
>
> 3
> 2
> 1
>
Having thought about this some more,
the function name should of course be jsonb_unnest(),
similar to how unnest() works for normal arrays:
SELECT unnest(array[[3,2],[1,4]]);
unnest
3
2
1
4
(4 rows)
SELECT jsonb_unnest('[[3,2],[1,4]]'::jsonb);
jsonb_unnest
---
t's common enough to motivate a new param:
jsonb_array_elements(from_json jsonb [, recursive boolean ])
Or as a separate function. Below is a PoC in PL/pgSQL:
CREATE OR REPLACE FUNCTION jsonb_array_elements_recursive(from_json jsonb, OUT
value jsonb)
RETURNS SETOF jsonb
LANGUAGE plpgsql
15 matches
Mail list logo