JSON Data Type | Casting JSON Data | Teradata Vantage - Casting JSON Data - Advanced SQL Engine - Teradata Database

JSON Data Type

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-27
dita:mapPath
uwa1591040057999.ditamap
dita:ditavalPath
uwa1591040057999.ditaval
dita:id
B035-1150
lifecycle
previous
Product Category
Teradata Vantageā„¢
Vantage provides casting functionality for a JSON type.
  • The JSON type can be cast to all other forms of the JSON type.
  • The JSON type can be cast to a JSON type of a different character set, such as JSON LATIN from JSON UNICODE.
  • The JSON type can be cast to and from VARCHAR and CLOB of the same character set:
    • VARCHAR(32000) CHARACTER SET UNICODE
    • VARCHAR(64000) CHARACTER SET LATIN
    • CLOB(8388096) CHARACTER SET UNICODE
    • CLOB(16776192) CHARACTER SET LATIN
  • The JSON type can be cast to a CHAR of the same character set:
    • CHAR(32000) CHARACTER SET UNICODE
    • CHAR(64000) CHARACTER SET LATIN
  • A JSON type specified with a binary storage format can be cast to and from BYTE, VARBYTE, or BLOB.

If you cast a JSON type to or from VARCHAR/CHAR and you do not specify a character set, the character set of the JSON type is used.

The casting functionality can be implicitly invoked, and the format of the data cast to/from in the text conforms to JSON syntax.

If the input to CAST is an empty JSON object, for example SELECT CAST( '' AS JSON);, the cast routine returns an empty JSON object.

When a dot notation expression is present in a CAST statement, the database attempts to return the desired data type without performing an explicit cast. This provides a performance boost in terms of data conversion. In addition, if the conversion fails, a NULL value is returned instead of an error. This is useful for handling dirty data that may contain anomalies not matching the desired target data type.

When casting a JSON dot notation expression to the following data types and the conversion fails, an error is returned instead of a NULL value:
  • TIME or TIMESTAMP
  • DATE
  • LOB or CLOB
  • UDT

If any truncation of data occurs as a result of the cast, a NULL value is returned.