JSON Data Type | Importing and Exporting | VantageCloud Lake - Importing and Exporting JSON Data - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

Regardless of storage format, the default format for JSON data to be imported to or exported from Vantage is CLOB (character) based. You can also use the predefined transform groups to convert objects to BLOB, VARCHAR, and VARBYTE. Transforms to and from BLOB or VARBYTE are in BSON format. For more information about the transform groups, see JSON Type Transform Groups.

Data can also be imported to and exported from the database in BSON format by using constructor/instance methods or cast functionality. Any import/export utilities that can use constructor/instance methods of the JSON type or cast functionality may be used to import or export BSON data.

Data cannot be imported to or exported from the database in the UBJSON format.

Importing and Exporting JSON Data in BSON Format

To import JSON data in BSON format, use one of the following:
  • A transform group that transforms BLOB or VARBYTE to JSON data
  • CAST BYTE, VARBYTE, or BLOB expression to JSON data
  • NEW JSON constructor method with BYTE, VARBYTE, or BLOB data
To export JSON data in BSON format, use one of the following:
  • A transform group that transforms JSON data in any format to BLOB or VARBYTE
  • CAST expression to cast JSON data in any format to BYTE, VARBYTE, or BLOB
  • AsBSON method on JSON data in any format

For BSON, numeric types are serialized in little-endian format. Data imported to or exported from the database in BSON format is expected to be in little-endian format. When exporting BSON data, Vantage serializes numeric types in little-endian format.

If data is imported to the database in BSON format, any numeric data must be in little-endian format. Failure to serialize numeric types in this manner corrupts data, because the database cannot detect the improperly serialized numeric data.

If data is imported to the database in JSON text format, the numeric types are represented by their character equivalents. For example, the number 1 is represented as the character 'U+0031' in UNICODE. When converting numeric types represented in text format to their BSON equivalents,Vantage serializes the BSON equivalents in little-endian format.

When JSON data that was stored in BSON format is exported as text, Vantage also makes sure that the little-endian serialized numeric values are properly converted to their text equivalents.

Conversion of Numeric Types in Text Format to and from UBJSON Format

For UBJSON, numeric types are serialized in little-endian format in Vantage.

If data is imported to the database in JSON text format, the numeric types are represented by their character equivalents. For example, the number 1 is represented as the character 'U+0031' in UNICODE. When converting numeric types represented in text format to their UBJSON equivalents,Vantage serializes the UBJSON equivalents in little-endian format.

When JSON data that was stored in UBJSON format is exported as text, Vantage also makes sure that the little-endian serialized numeric values are properly converted to their text equivalents.

String Encodings

Both BSON and UBJSON encode strings in the UTF8 character set. However, UTF8 is not supported as a character set inside Vantage. If data is imported to the database in JSON text format and is stored in one of the binary storage formats, conversion is performed as described in Storage Format Conversions.

All character string data is converted from the source data (either in LATIN or UNICODE) to its UTF8 equivalent. Any errors encountered have a failed operation. No errors are ignored.

Similarly, when data which was stored as BSON or UBJSON is exported as JSON text, all strings encoded as UTF8 are converted to the appropriate character set (LATIN or UNICODE), and any errors encountered have a failed operation.

If data stored in binary storage formats cannot be exported as JSON text due to a character translation error, you can export the data as BSON using an instance method or casts of the JSON type.