Examples | DATASET Constructor Method | Teradata Vantage - Examples: DATASET Constructor Method - 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ā„¢

Example: Creating a CSV DATASET Value

The character set defaults to the current server character set.

SELECT new DATASET('{"field_delimiter" : ",", "record_delimiter" : ";" }',
                   'Id,Item,Qnty,Price;103,brush,33,0.99;102,paint,2,0.69',
                   CSV);

Result:

  > Id,Item,Qnty,Price;103,brush,33,0.99;102,paint,2,0.69

Example: Creating a CSV DATASET Value with a UNICODE Character Set

SELECT new DATASET('{"field_delimiter" : ",", "record_delimiter" : ";" }',
                   'Id,Item,Qnty,Price;103,brush,33,0.99;102,paint,2,0.69',
                   CSV, Unicode);

Result:

 > Id,Item,Qnty,Price;103,brush,33,0.99;102,paint,2,0.69

Creating an Avro DATASET Value

In this example, create an Avro DATASET value, and then select it out in the JSON format by using the toJson() method for readability.

SELECT new DATASET(
    '{"type":"record",
      "name":"rec_0",
      "fields":[
                {"name":"ID","type":"int"},
                {"name":"First","type":"string"},
                {"name":"Middle","type":"string"},
                {"name":"Last","type":"string"}]}',
                   '081246726564657269636B064A6F6E1057696C6C69616D73'XB,
                   Avro).toJson();

Result:

> {"ID":4,"First":"Frederick","Middle":"Jon","Last":"Williams"}