JSON Support | Teradata Vantage - Teradata Vantage Support for JSON - Advanced SQL Engine - Teradata Database

JSON Data Type

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
September 2020
Language
English (United States)
Last Update
2021-01-23
dita:mapPath
gzn1554761068186.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1150
lifecycle
previous
Product Category
Teradata Vantage™

JSON (Javascript Object Notation) is a data interchange format, often used in web applications to transmit data. JSON has been widely adopted by web application developers because, compared to XML, it is easier for humans to read and write, and for machines it is easier to generate and parse. JSON documents can be stored and processed in Teradata Vantage.

Vantage can store JSON records as a JSON document or store JSON records in relational format. Vantage provides the following support for JSON data:
  • Ability to store JSON data in text and binary (BSON, UBJSON) storage formats.
  • Methods, functions, and stored procedures that operate on the JSON data type, such as parsing and validation.
  • Shredding functionality that allows you to extract values from JSON documents, and store the extracted data in relational format.
  • Publishing functionality that allows you to publish the results of SQL queries in JSON format.
  • Schema-less or dynamic schema with the ability to add a new attribute without changing the schema. Data with new attributes is immediately available for querying. Rows without the new column can be filtered out.
  • Use existing join indexing structures on extracted portions of the JSON data.
  • Apply advanced analytics to JSON data.
  • Functionality to convert an ST_Geometry object into a GeoJSON value and a GeoJSON value into an ST_Geometry object.
  • Allows JSON data of varying maximum lengths, and JSON data can be internally compressed.
  • Collect statistics on extracted portions of the JSON data.
  • Use standard SQL to query JSON data.
  • JSONPath provides simple traversal and regular expressions with wildcards to filter and navigate complex JSON documents.

Client Support for JSON

The following table describes the support provided by the Teradata client products for the JSON data type.

Client Product JSON Support Provided
CLI Full native DBS support.
ODBC

The ODBC specification does not have a unique data type code for JSON. Therefore, the ODBC driver maps the JSON data type to SQL_LONGVARCHAR or SQL_WLONGVARCHAR, which are the ODBC CLOB data types. The metadata clearly differentiates between a Vantage CLOB data type mapped to SQL_LONGVARCHAR and a Vantage JSON data type mapped to SQL_LONGVARCHAR.

The ODBC driver supports LOB Input, Output and InputOutput parameters. Therefore, it can load JSON data. Also the Catalog (Data Dictionary) functions support JSON.

JDBC
  • Teradata JDBC Driver 15.00.00.11 and later support the JSON data type.
  • The Teradata JDBC Driver offers Vantage-specific functionality for an application to use the PreparedStatement or CallableStatement setObject method to bind a Struct value to a question-mark parameter marker as a JSON data type. An application can also insert VARCHAR or CLOB values into JSON destination columns.
  • When an application uses the Vantage-specific functionality of specifying a JSON value as a Struct value, the Struct value must contain one of the following attributes: String, Reader, Clob, or null. If the Struct contains a Reader attribute, the Struct must also contain a second attribute that is an Integer type specifying the number of characters in the stream.
  • JSON values are retrieved from Vantage as CLOB values. An application can use result set metadata or parameter metadata to distinguish a CLOB value from a JSON value.
.NET Data Provider
  • JSON data type is externalized as a CLOB. Applications can use TdClob, TdDataReader.GetChars, or TdDataReader.GetString to retrieve a JSON value.
  • Applications can send a JSON value as String or TextReader to the database.
  • Schema Collections (Data Dictionary) also support the JSON data type.
Teradata Parallel Transporter (Teradata PT) JSON columns are treated exactly like CLOB columns and subject to the same limitations. JSON columns cannot exceed 16 MB (16,776,192 LATIN characters or 8,388,096 UNICODE characters). Teradata PT accommodates the JSON keyword in object schema but internally converts it to CLOB. Import and export are both fully supported.
BTEQ

The JSON keyword cannot be used in the USING data statement; therefore, JSON values must be referred to as either CLOB or VARCHAR. For VARCHAR, the JSON value cannot exceed 64 KB (64000 LATIN characters or 32000 UNICODE characters).

Currently, BTEQ does not support deferred mode LOB transfer for server to client. Only non-deferred mode JSON transfer is supported for server to client, and the maximum size of an output row is limited to 64 KB.

Standalone Utilities No support.
For more information about the Teradata client products, see the following documents:
  • Teradata® Call-Level Interface Version 2 Reference for Mainframe-Attached Systems, B035-2417
  • Teradata® Call-Level Interface Version 2 Reference for Workstation-Attached Systems, B035-2418
  • ODBC Driver for Teradata® User Guide, B035-2509
  • Teradata JDBC Driver Reference, available at https://teradata-docs.s3.amazonaws.com/doc/connectivity/jdbc/reference/current/frameset.html
  • Teradata® Parallel Transporter Reference, B035-2436
  • Teradata® Parallel Transporter User Guide, B035-2445
  • Basic Teradata® Query Reference, B035-2414

Terminology

  • A JSON document is any string that conforms to the JSON format. See JSON String Syntax.
  • A JSON document can be structured as an object or as an array.
  • A JSON object consists of zero or more name:value pairs delimited by curly braces ( { } ).
  • The value portion of a JSON object can be a single string, number, Boolean (true or false), null, array, or object.
  • A JSON array is an ordered list of zero or more values delimited by square brackets ( [ ] ). Those values can be a single string, number, Boolean true or false, null, array, or object.
  • JSON documents that are stored and used as Vantage JSON data types can be referred to as JSON instances or JSON type instances.
The following is an example of a JSON document.
{
    "name": "Product",
    "properties": {
        "id": {
            "type": "number",
            "description": "Product identifier",
            "required": true
        },
        "name": {
            "type": "string",
            "description": "Name of the product",
            "required": true
        },
        "price": {
            "type": "number",
            "minimum": 0,
            "required": true
        },
        "tags": {
            "type": "array",
            "items": {
                "type": "string"
            }
        },
        "stock": {
            "type": "object",
            "properties": {
                "warehouse": {
                    "type": "number"
                },
                "retail": {
                    "type": "number"
                }
            }
        }
    }
}