1.1 - 8.10 - Unpack_MLE Example: Delimiter for Virtual Columns - Teradata Vantage

Teradata Vantage™ - Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
1.1
8.10
Release Date
October 2019
Content Type
Programming Reference
Publication ID
B700-4003-079K
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

Because comma is the default delimiter, the Delimiter syntax element is optional.

SELECT * FROM Unpack_MLE (
  ON ville_tempdata
  USING
  TargetColumn ('packed_temp_data')
  OutputColumns ('city','state','temp_F')
  OutputDataTypes ('varchar(9)','varchar(9)','float')
  Delimiter (',')
  Regex ('(.*)')
  RegexSet (1)
  IgnoreInvalid ('true')
) AS dt ORDER BY sn;

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

Download a zip file of all examples and a SQL script file that creates their input tables from the attachment in the left sidebar.