1.0 - 8.00 - Unpack Example 1: Delimiter Separates Virtual Columns - Teradata Vantage

Teradata® Vantage Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
1.0
8.00
Release Date
May 2019
Content Type
Programming Reference
Publication ID
B700-4003-098K
Language
English (United States)

Input

The input table, ville_tempdata, is a collection of temperature readings for two cities, Nashville and Knoxville, in the state of Tennessee. In the column of packed data, the delimiter comma (,) separates the virtual columns. The last row contains invalid data.

ville_tempdata
sn packed_temp_data
10 Nashville,Tennessee,35.1
11 Nashville,Tennessee,36.2
12 Nashville,Tennessee,34.5
13 Nashville,Tennessee,33.6
14 Nashville,Tennessee,33.1
15 Nashville,Tennessee,33.2
16 Nashville,Tennessee,32.8
17 Nashville,Tennessee,32.4
18 Nashville,Tennessee,32.2
19 Nashville,Tennessee,32.4
20 Thisisbaddata

SQL Call

SELECT * FROM Unpack (
  ON ville_tempdata
  USING
  TargetColumn ('packed_temp_data')
  OutputColumns ('city', 'state', 'temp_f')
  OutputDataTypes ('varchar', 'varchar', 'real')
  Delimiter (',') 
  Regex ('(.*)')
  RegexSet (1)
  IgnoreInvalid ('true')
) AS dt ORDER BY sn;
Because comma is the default delimiter, the Delimiter argument in the preceding call is optional.

Output

Because of IgnoreInvalid ('true'), the function did not fail when it encountered the row with invalid data, but it did not output that row.

city state temp_f sn
Nashville Tennessee 35.1 10
Nashville Tennessee 36.2 11
Nashville Tennessee 34.5 12
Nashville Tennessee 33.6 13
Nashville Tennessee 33.1 14
Knoxville Tennessee 33.2 15
Knoxville Tennessee 32.8 16
Knoxville Tennessee 32.4 17
Knoxville Tennessee 32.2 18
Knoxville Tennessee 32.4 19