Serializing with JSON
Setup
The following describes through examples how a DeltaStream query converts JSON payloads to DeltaStream’s Data Types when reading from a Database or Database.
The following examples use the stream defined below:
CREATE STREAM jsonExample (
"booleanValue" BOOLEAN,
"stringValue" VARCHAR,
"tinyIntValue" TINYINT,
"smallIntValue" SMALLINT,
"intValue" INTEGER,
"bigIntValue" BIGINT,
"floatValue" FLOAT,
"doubleValue" DOUBLE,
"decimalValue" DECIMAL(4, 3),
"dateValue" DATE,
"timeValue" TIME,
"timestampValue" TIMESTAMP(3),
"timestampLtzValue" TIMESTAMP_LTZ,
"bytesValue" VARBINARY,
"arrayValue" ARRAY<VARCHAR>,
"mapValue" MAP<VARCHAR, BIGINT>,
"structValue" STRUCT<col1 BIGINT>
) WITH (
'topic' = 'jsonExample', 'value.format' = 'JSON'
);Simple Example
With the query:
Partial Record Example
When JSON records are missing fields specified by the CREATE STREAM DDL statement, those fields are given the value NULL in the output record. In the opposite case — when JSON records have fields that aren’t specified by the CREATE STREAM DDL statement — those fields are ignored.
With the query:
Mismatched Types Example
Boolean
With the query:
Character String
With the query:
Numeric
With the query:
Date and Time
Binary String
With the query:
Constructed Data Types
With the query:
Array
Map
Struct
Last updated

