Example: Changing the Key Names in the Avro Record - Analytics Database - Teradata Vantage

DATASET Data Type

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2023-10-30
dita:mapPath
bka1628112240653.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
ekk1458586304878
lifecycle
latest
Product Category
Teradata Vantageā„¢

To change the key names in the resulting JSON documents, use the SCHEMA custom clause.

SELECT * FROM CSV_TO_JSON
(
	ON (SELECT csvFile FROM myCSVTable09 WHERE id=2) 
	USING SCHEMA('{"record_delimiter":"#", "field_names":["a1","a2","a3","a4","a5","a6","a7"]}')
) AS csvJSON ORDER BY data."a1";

Result:

> {"a1":"55", "a2":"bicycle", "a3":"red", "a4":"boys", "a5":"1", "a6":"100.00", "a7":"100.00"}
> {"a1":"88", "a2":"toy boat", "a3":"pink", "a4":null, "a5":"1", "a6":"15.10", "a7":"15.10"}
> {"a1":"105", "a2":"soap", "a3":null, "a4":null, "a5":"1", "a6":"0.99", "a7":"0.99"}