READ_NOS | JSON_KEYS Function | Teradata Vantage - 17.05 - Example: Using READ_NOS to Display Keys in a JSON File without an Extension - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Manipulation Language

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
Release Date
January 2021
Content Type
Programming Reference
Publication ID
B035-1146-175K
Language
English (United States)

This example uses the READ_NOS table operator with JSON_KEYS function to display the keys in a JSON file.

Display Keys in a JSON File

This SELECT statement uses the READ_NOS_json_intable_fm function mapping, which includes the ANY IN TABLE clause, with the JSON_KEYS function to display the keys in the external JSON file 27.

Create the function mapping READ_NOS_json_intable_fm, if not already created. See Example: Function Mapping Definition Using ANY IN TABLE for JSON Data Files.

Perform the READ_NOS:

SELECT DISTINCT * FROM JSON_KEYS (
ON (
  SELECT payload FROM READ_NOS_json_intable_fm (
    ON (SELECT CAST(NULL AS JSON) )
    USING
    LOCATION('/s3/td-usgs.s3.amazonaws.com/DATA/09380000/2018/06/27')
    RETURNTYPE('NOSREAD_RECORD')
  ) AS read_nos_query
) AS json_on_keys_query ) AS d ;

Result:

JSONKeys        
 --------------- 
 "Flow"         
 "Precipitation"
 "Conductance"  
 "datetime"     
 "site_no"      
 "Temp"         
 "GageHeight"