1

I am using the json_extract function in PrestoSQL, however, if the key-value pair appears with a negative integer in the value such as

{"foo":-12345, "bar": 12345}

json_extract(json, '$.foo') will return NULL but

json_extract(json, '$.bar') will return 12345

json_extract_scalar also produces the same.

What is the workaround for extracting negative integers in Presto?

Manfred Moser
  • 29,539
  • 13
  • 92
  • 123
iskandarblue
  • 7,208
  • 15
  • 60
  • 130

1 Answers1

1

It works as expected in current master (Presto 320):

presto:default> SELECT json_extract(JSON '{"foo":-12345, "bar": 12345}', '$.foo');
 _col0
--------
 -12345
(1 row)
presto:default> SELECT json_extract_scalar(JSON '{"foo":-12345, "bar": 12345}', '$.foo');
 _col0
--------
 -12345
(1 row)
Piotr Findeisen
  • 19,480
  • 2
  • 52
  • 82