I'm trying the following query:
SELECT (json_data->'position'->'lat') + 1.0 AS lat FROM updates LIMIT 5;
(The +1.0 is just there to force conversion to float. My actual queries are far more complex, this query is just a test case for the problem.)
I get the error:
ERROR: operator does not exist: jsonb + numeric
If I add in explicit casting:
SELECT (json_data->'position'->'lat')::float + 1.0 AS lat FROM updates LIMIT 5;
the error becomes:
ERROR: operator does not exist: jsonb + double precesion
I understand that most jsonb values cannot be cast into floats, but in this case I know that the lats are all JSON numbers.
Is there a function which casts jsonb values to floats (or return NULLs for the uncastable)?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…