From: | ilmari(at)ilmari(dot)org (Dagfinn Ilmari Mannsåker ) |
---|---|
To: | Bruce Momjian <bruce(at)momjian(dot)us> |
Cc: | Eugen Konkov <kes-kes(at)yandex(dot)ru>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Proposition for autoname columns |
Date: | 2020-11-12 00:18:49 |
Message-ID: | 87d00jctqu.fsf@wibble.ilmari.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Bruce Momjian <bruce(at)momjian(dot)us> writes:
> On Mon, Nov 2, 2020 at 05:05:29PM +0200, Eugen Konkov wrote:
>> Hello Pgsql-hackers,
>>
>> When selecting data from json column it named as '?column?'
>> tucha=# select info->>'suma', docn from document order by id desc limit 5;
>> ?column? | docn
>> ----------+------
>> 665.97 | 695
>> 513.51 | 632
>> 665.97 | 4804
>> 492.12 | 4315
>> 332.98 | 1302
>> (5 rows)
>>
>> It would be useful if the name of column will be autoassigned based on
>> name of json key. Like at next query:
>>
>> tucha=# select info->>'suma' as suma, docn from document order by id desc limit 5;
>> suma | docn
>> --------+------
>> 665.97 | 695
>> 513.51 | 632
>> 665.97 | 4804
>> 492.12 | 4315
>> 332.98 | 1302
>> (5 rows)
>>
>>
>> Would it be useful this auto assigned name for column from json?
>
> I think we could do it, but it would only work if the column was output
> as a single json value, and not a multi-key/value field. I am afraid if
> we tried to do it, the result would be too inconsistent to be useful.
Could this be done via the support function, so that the top-level
operator/function in each select list item can return a suggested column
name if the relevant arguments are constants?
- ilmari
--
- Twitter seems more influential [than blogs] in the 'gets reported in
the mainstream press' sense at least. - Matt McLeod
- That'd be because the content of a tweet is easier to condense down
to a mainstream media article. - Calle Dybedahl
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2020-11-12 00:55:52 | Re: Proposition for autoname columns |
Previous Message | Tom Lane | 2020-11-11 22:46:59 | Returning NULL from satisfies_hash_partition() is a bad idea |