Re: JSON Path and GIN Questions

Поиск
Список
Период
Сортировка
От David E. Wheeler
Тема Re: JSON Path and GIN Questions
Дата
Msg-id 7A19C6A6-DEB4-426D-BC6E-9F35A691E567@justatheory.com
обсуждение исходный текст
Ответ на Re: JSON Path and GIN Questions  (Erik Wienhold <ewie@ewie.name>)
Ответы Re: JSON Path and GIN Questions  (Erik Wienhold <ewie@ewie.name>)
Список pgsql-hackers
On Sep 12, 2023, at 21:00, Erik Wienhold <ewie@ewie.name> wrote:

>> If so, I’d like to submit a patch to the docs talking about this, and
>> suggesting the use of jsonb_path_query() to test paths to see if they return
>> a boolean or not.
>
> +1

I’ve started work on this; there’s so much to learn! Here’s a new example that surprised me a bit. Using the GPS
trackerexample from the docs [1] loaded into a `:json` psql variable, this output of this query makes perfect sense to
me:

david=# select jsonb_path_query(:'json', '$.track.segments.location[*] ? (@ < 14)');
 jsonb_path_query
------------------
 13.4034
 13.2635

Because `[*]` selects all the values. This, however, I did not expect:

david=# select jsonb_path_query(:'json', '$.track.segments.location ? (@[*] < 14)');
 jsonb_path_query
------------------
 13.4034
 13.2635
(2 rows)

I had expected it to return two single-value arrays, instead:

 [13.4034]
 [13.2635]

It appears that the filter expression is doing some sub-selection, too. Is that expected?

Best,

David

  [1]: https://www.postgresql.org/docs/current/functions-json.html#FUNCTIONS-SQLJSON-PATH

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: "David E. Wheeler"
Дата:
Сообщение: Re: JSON Path and GIN Questions
Следующее
От: Nathan Bossart
Дата:
Сообщение: Re: Add 'worker_type' to pg_stat_subscription