Error loading FLOAT INFINITY using FJSONPARSER

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!

Tagged:

Best Answer

  • Bryan_HBryan_H Vertica Employee Administrator
    Answer ✓

    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)

Answers

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file