Skip to main content
Question

Error loading FLOAT INFINITY using FJSONPARSER

  • January 16, 2023
  • 2 replies
  • 7 views

Sergey_Cherepan_1
Forum|alt.badge.img+2

Hi,

I found error on loading JSON into flex table.
Vertica report something like:

udx/supported/flextable/FJsonParser.cpp:35], error code: 0, message: Malformed record found: Error [Invalid value.] at character 589

Checking JSON file, it contains FLOAT Infinity:

"myfield" : Infinity

Typically myfield contains FLOAT like "myfield":4.567

but in this case it is word Infinity, without double quotes.

Quick check show that Vertica do support Infinity for FLOAT:

https://www.vertica.com/docs/12.0.x/HTML/Content/Authoring/SQLReferenceManual/LanguageElements/Literals/Number-typeLiterals.htm

Vertica follows the IEEE specification for floating point, including NaN (not a number) and Infinity (Inf).

Question:
What to do to make FJSONPARSER to load Infinity

Complain:
Error message from FJSONPARSER can be more explanatory.

Thanks!

2 replies

Bryan_H
Forum|alt.badge.img+2
  • Participating Frequently
  • January 17, 2023

It looks like you can load NaN and Inf as float by enclosing with double quotes:
d2=> create flex table floatinf();
d2=> copy floatinf from local stdin parser fjsonparser();
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself.
>> {"f":1.23}
>> {"f":4.56}
>> {"f":"Inf"}
>> {"f":"NaN"}
>> .

Rows Loaded

4
(1 row)

d2=> select f::float from floatinf;

f

1.23
4.56
Infinity
NaN
(4 rows)


Sergey_Cherepan_1
Forum|alt.badge.img+2
  • Author
  • Participating Frequently
  • January 17, 2023

Thanks!