From: | Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Nikita Glukhov <n(dot)gluhov(at)postgrespro(dot)ru>, Aleksander Alekseev <a(dot)alekseev(at)postgrespro(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Anthony Bykov <a(dot)bykov(at)postgrespro(dot)ru> |
Subject: | Re: Jsonb transform for pl/python |
Date: | 2018-07-11 10:52:09 |
Message-ID: | CAPpHfdufV+auHuSChG2og7bjWyLxHwZy8iZSsg0uVkC=+kkqNQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Jul 11, 2018 at 12:30 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> writes:
> > On 6/23/18 01:44, Nikita Glukhov wrote:
> >> We are simply trying first to convert numeric to int64 if is does not have
> >> digits after the decimal point, and then construct Python Int instead of
> >> Decimal. Standard Python json.loads() does the same for exact integers.
>
> > We just had a very similar but not identical discussion in the thread
> > about the PL/Perl transforms, where we rejected the proposal. Other
> > comments on this one?
>
> I can sympathize with the speed concern, but the proposed patch produces
> a functional change (ie, you get a different kind of Python object, with
> different behaviors, in some cases). That seems to me to be a good reason
> to reject it.
Nevertheless, as Nikita pointed, json.loads() performs the same in
Python. See an example for python 2.7.10.
>>> import json
>>> type(json.loads('1'))
<type 'int'>
>>> type(json.loads('1.0'))
<type 'float'>
So, from postgres point of view this behavior is wrong. But on
another hand why don't let python transform to behave like a python?
------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
From | Date | Subject | |
---|---|---|---|
Next Message | Ashutosh Bapat | 2018-07-11 11:02:50 | Re: Expression errors with "FOR UPDATE" and postgres_fdw with partition wise join enabled. |
Previous Message | Dilip Kumar | 2018-07-11 10:50:37 | Re: partition pruning doesn't work with IS NULL clause in multikey range partition case |