Filter the JSON Payload Column | Native Object Store ( NOS ) | Teradata Vantage - 17.10 - Filtering on the Payload Column of a Foreign Table - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - Native Object Store Getting Started Guide

Advanced SQL Engine
Teradata Database
Release Number
Release Date
July 2021
Content Type
Programming Reference
Publication ID
English (United States)
Path filters usually make queries more efficient because they access less data from external storage.

The examples and results show a sample river flow data set. To use your own data, replace the table and column names, and authorization object.

  1. To run NOS-related commands, log on to the database as a user with the required privileges.
  2. Create a foreign table using a custom PATHPATTERN. Use the authorization object created in Controlling Foreign Table Access with an AUTHORIZATION Object:
    CREATE FOREIGN TABLE riverflow_json_path
    , EXTERNAL SECURITY authorization_object
    USING (
    PATHPATTERN('$data/$siteno/$year/$month/$day') );

    See Variable Substitutions for Examples for the credentials and location values for the sample river flow data set.

  3. Run a query using a payload filter only:
    SELECT TOP 2 payload.GageHeight,payload.Flow
    FROM riverflow_json_path
    WHERE payload.site_no = '09394500';


    TheGageHeight    TheFlow
    -------------  ---------
             6.39      45.60
             5.04       3.53
  4. Because the site_no attribute also appears as part of the path, a better way to write this query (that uses path filtering instead of payload filtering) is:
    SELECT TOP 2 payload.GageHeight,payload.Flow
    FROM riverflow_json_path
    WHERE $path.$siteno = '09394500';

    Using path filtering is more efficient. Path filtering reduces the number of external objects read. You can view the query log, if it is enabled, to see that fewer external objects are accessed and less data is transferred with the second query.

    For details on the NOS-related DBQL fields, see the Orange Book, Native Object Store: Teradata Vantage™ Advanced SQL Engine, TDN0009800 and Teradata Vantage™ - Data Dictionary, B035-1092.


    TheGageHeight    TheFlow
    -------------  ---------
             6.40      62.90
             6.39       40.1

    Note, TOP does not return the same results each time it is run.