JSONParser Example: ERROR_HANDLER - Teradata Vantage

Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
8.10
1.1
Published
October 2019
Language
English (United States)
Last Update
2019-12-31
dita:mapPath
ima1540829771750.ditamap
dita:ditavalPath
jsj1481748799576.ditaval
dita:id
B700-4003
lifecycle
previous
Product Category
Teradata Vantageā„¢

Input

The input table, json_parser_data_3, is the same as json_parser_data in JSONParser Example: Nondefault Values, except for a formatting error: The data column is missing a closing quotation mark and a colon after the menuitem field.

json_parser_data_3
id data
1
{"menu": {
  "id": "1",
  "value": "File",
  "popup": {
    "menuitem [
      {"value": "New", "onclick": "CreateNewDoc()"},
      {"value": "Open", "onclick": "OpenDoc()"},
      {"value": "Close", "onclick": "CloseDoc()"}
    ]
  }
}}

SQL Call

SELECT * FROM JSONParser(
  ON json_parser_data_3
  USING
  TextColumn('data1')
  Nodes('menuitem/value')
  ErrorHandler('true; data1')
) AS dt ;

Output

 out_nodeid out_parent_node menuitem_value errorhandler                                                                                                                                                                                                                        
 ---------- --------------- -------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
          0 NULL            NULL           {"menu": {  "id": "1",  "value": "File",  "popup": {    "menuitem [      {"value": "New", "onclick": "CreateNewDoc()"},      {"value": "Open", "onclick": "OpenDoc()"},      {"value": "Close", "onclick": "CloseDoc()"}    ]  }}};

Download a zip file of all examples and a SQL script file that creates their input tables from the attachment in the left sidebar.