16.20 - Unpack Example: Delimiter Separates Virtual Columns - Teradata Database - Teradata Vantage NewSQL Engine

Teradata Vantage™ - NewSQL Engine Analytic Functions

Teradata Database
Teradata Vantage NewSQL Engine
Release Number
Release Date
July 2019
Content Type
Programming Reference
Publication ID
English (United States)


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.

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
  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 syntax element in the preceding call is optional.


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 3.51000000000000E 001 10
Nashville Tennessee 3.62000000000000E 001 11
Nashville Tennessee 3.45000000000000E 001 12
Nashville Tennessee 3.36000000000000E 001 13
Nashville Tennessee 3.31000000000000E 001 14
Nashville Tennessee 3.32000000000000E 001 15
Nashville Tennessee 3.28000000000000E 001 16
Nashville Tennessee 3.24000000000000E 001 17
Nashville Tennessee 3.22000000000000E 001 18
Nashville Tennessee 3.24000000000000E 001 19