Of course, my bad!

-- Regular cast syntax
SELECT ROUND(CAST((X/Y) AS NUMERIC), 2) FROM (VALUES (1, 2), (NULLIF(5, 5),
NULLIF(5, 5))) A(X, Y)

Thanks,
Gelbana


On Sun, Jun 16, 2019 at 8:43 PM Julian Hyde <[email protected]> wrote:

> Can you reproduce it with regular cast syntax? Make it as easy as possible
> for others to help you.
>
> Julian
>
> > On Jun 16, 2019, at 11:24 AM, Muhammad Gelbana <[email protected]>
> wrote:
> >
> > The following query throws a NPE in the generated code because it assumes
> > the divided value to be an initialized Java object (Not null), which is
> > fine for the first row, but not for the second.
> >
> > SELECT ROUND((X/Y)::NUMERIC, 2)
> > FROM (VALUES (1, 2), (NULLIF(5, 5), NULLIF(5, 5))) A(X, Y)
> >
> > If I modify the query a little bit, it runs ok:
> > -- No casting
> > SELECT ROUND((X/Y), 2) FROM (VALUES (1, 2), (NULLIF(5, 5), NULLIF(5, 5)))
> > A(X, Y)
> >
> > -- No rounding
> > SELECT (X/Y)::NUMERIC FROM (VALUES (1, 2), (NULLIF(5, 5), NULLIF(5, 5)))
> > A(X, Y)
> >
> > What could be causing this ? Any hints ?
> > And was this reported before or should I create a new ticket ?
> >
> > Thanks,
> > Gelbana
>

Reply via email to