Unpack Function Example | Teradata Vantage - Example: More Input Columns than Output Columns - Analytics Database

Database Analytic Functions

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-10-04
dita:mapPath
gjn1627595495337.ditamap
dita:ditavalPath
ayr1485454803741.ditaval
dita:id
jmh1512506877710
lifecycle
latest
Product Category
Teradata Vantageā„¢

Unpack Input

The input table is ville_tempdata1 with no delimiter that separates virtual columns in the packed data. Its packed_temp_data column has three virtual columns.

ville_tempdata1
sn packed_temp_data
10 NashvilleTennessee35.1
11 NashvilleTennessee36.2
12 NashvilleTennessee34.5
13 NashvilleTennessee33.6
14 NashvilleTennessee33.1
15 NashvilleTennessee33.2
16 NashvilleTennessee32.8
17 NashvilleTennessee32.4
18 NashvilleTennessee32.2
19 NashvilleTennessee32.4
20 Thisisbaddata

Unpack SQL Call with More Input Columns than Output Columns

The OutputColumns syntax element specifies only two output column names.

SELECT * FROM Unpack (
  ON ville_tempdata1 AS InputTable
  USING
  TargetColumn ('packed_temp_data')
  OutputColumns ('city', 'state')
  OutputDataTypes ('varchar', 'varchar')
  ColumnLength ('9', '9') 
  Regex ('(.*)')
  RegexSet (1)
  IgnoreInvalid ('true')
) AS dt ORDER BY sn;

Unpack Output with More Input Columns than Output Columns

The output table has columns for the first two virtual input columns, but not for the third.

city state sn
Nashville Tennessee 10
Nashville Tennessee 11
Nashville Tennessee 12
Nashville Tennessee 13
Nashville Tennessee 14
Nashville Tennessee 15
Nashville Tennessee 16
Nashville Tennessee 17
Nashville Tennessee 18
Nashville Tennessee 19