17.10 - Examples - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Operators and User-Defined Functions

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Administration
Programming Reference
Publication ID
B035-1210-171K
Language
English (United States)

The following query returns a JSON document with feature name array for each FeatureUsage column in DBC.DBQLogTbl.

  • The FeatureUsage VARBYTE column.
  • The associated QueryID that maps into DBC.DBQLogTbl's QueryID.
    SELECT JsonTbl.QueryID (FORMAT '--Z(17)9'), JsonTbl.FeatureUsageJSON
    FROM TABLE(TD_SYSFNLIB.TD_DBQLFUL(DBC.DBQLogTbl.QueryID,DBC.DBQLogTbl.FeatureUsage))
    AS JsonTbl ORDER BY JsonTbl.QueryID;

This returns a JSON document with a list of features that the request used.

To avoid a complex SQL query, use DBC.QryLogFeatureUseJSON:

SELECT QueryID, FeatureJSON 
FROM QryLogFeatureUseJSON ;

Output of a request with five different features:

QueryID FeatureUsageJSON
307191834744036453 {"QueryID": "307191834744036453","FeatureInfo": ["Partition Primary Index","Multi-Level Partition Primary Index","User Defined Data Type","XML Data Type","Period Data Type"]}