17.10 - Example: Converting a DATASET STORAGE FORMAT CSV Value to AVRO - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - DATASET Data Type

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1198-171K
Language
English (United States)
In this example, each CSV record is converted to one output row composed of one AVRO record, along with its schema.
CREATE TABLE csv_table_1(pkey INTEGER,
csv DATASET STORAGE FORMAT CSV);
INSERT INTO csv_table_1 values(0,
'ItemID,ItemName,Quantity,Price;10021,Paint Brush,10,10.99;10033,Paint,3,24.99'); 
SELECT data.ToJson() FROM CSV_TO_AVRO
(
ON (SELECT csv FROM csv_table_1)
USING SCHEMA('{"record_delimiter":";"}')
) AS csv; 
> {"ItemID":"10021","ItemName":"Paint Brush","Quantity":"10","Price":
"10.99"}
> {"ItemID":"10033","ItemName":"Paint","Quantity":"3","Price":"24.99"}