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