Ingestion Rules for JSON

<< Click to Display Table of Contents >>

Navigation:  Integrating Blaze with Other Systems > Reading Data into s-Server > Reading from Other Sources  > File Formats for Reading > Reading JSON >

Ingestion Rules for JSON

Previous pageReturn to chapter overviewNext page

s-Server applies the following coercion rules when parsing JSON data. All NULL LITERALS are cast as NULL. For arrays and objects, s-Server will raise an error in all cases except for CHAR and VARCHAR, in which cases the source text of the array or object will be truncated or padded as necessary.

JSON source value

TRUE/FALSE literal.

Number

String

BIGINT

DECIMAL

DOUBLE

INT

SMALLINT

REAL

TINYINT

TRUE → 1

FALSE → 0

Raise an exception if the JSON number lies beyond the maximum or minimum boundary of the target type. If the number has any decimal digits (including the vacuous .0) and it is being ingested into an integer column, then raise an error.

If the string, without quotes, is a valid JSON number, then that number should be parsed and the rules for ingesting JSON numbers should be applied.

Otherwise (the unquoted value isn't a valid JSON number), an error is raised.

BINARY

VARBINARY

TRUE → Set the lowest bit of the resulting byte array and clear all other bits.

FALSE → Clear all bits in the resulting byte array.

For VARBINARY, coercions should result in a 1 byte array.

Raise an error.

If the string, without quotes, is a valid SQL Standard BINARY literal, then s-Server will ingest it, truncating and 0-filling as necessary. A Standard BINARY literal has the form X'...' where ... is a sequence of (case-insensitive) hex digits.

BOOLEAN

TRUE → TRUE

FALSE → FALSE

0 → FALSE

all other numbers → TRUE

s-Server applies the rules of java.lang.Boolean.parseBoolean(). If the lowercased string is equal to "TRUE", then the result is true. Otherwise, the result is FALSE.

CHAR

VARCHAR

TRUE → "TRUE"

FALSE →"FALSE"

The result string is truncated as necessary in order to fit into the target value's width.

Slap double-quotes around the number and then ingest subject to the truncation/padding rules for strings.

If the string won't fit in the target SQL character value, then the excess trailing characters should be discarded

DATE

TIME

TIMESTAMP

Boolean coercion to TIME should raise an error just like boolean coercion to DATE and TIMESTAMP.

Raise an error.

OK if the string parses as a DATE/TIME/TIMESTAMP according to the liberal rules being implemented by Jack right now. Otherwise, raise an error.