Pack Function Example | Teradata Vantage - Example: Default Options - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

This example specifies the default options for Delimiter and IncludeColumnName.

Pack with Default Options SQL Call

SELECT * FROM Pack (
  ON ville_temperature
  USING
  Delimiter (',')
  OutputColumn ('packed_data')
  IncludeColumnName ('true')
  TargetColumns ('[1:4]')
  Accumulate ('sn')
) AS dt ORDER BY 2;

Pack with Default Options Output

The columns specified by TargetColumns are packed in the column packed_data. Virtual columns are separated by commas, and each virtual column value is labeled with its column name. The input column sn, which was not specified by TargetColumns, is unchanged in the output table.

packed_data sn
city:Nashville,state:Tennessee,period:2022-01-01 00:00:00,temp_f:35.1 1
city:Nashville,state:Tennessee,period:2022-01-01 01:00:00,temp_f:36.2 2
city:Nashville,state:Tennessee,period:2022-01-01 02:00:00,temp_f:34.5 3
city:Nashville,state:Tennessee,period:2022-01-01 03:00:00,temp_f:33.6 4
city:Nashville,state:Tennessee,period:2022-01-01 04:00:00,temp_f:33.1 5
city:Knoxville,state:Tennessee,period:2022-01-01 03:00:00,temp_f:33.2 6
city:Knoxville,state:Tennessee,period:2022-01-01 04:00:00,temp_f:32.8 7
city:Knoxville,state:Tennessee,period:2022-01-01 05:00:00,temp_f:32.4 8
city:Knoxville,state:Tennessee,period:2022-01-01 06:00:00,temp_f:32.2 9
city:Knoxville,state:Tennessee,period:2022-01-01 07:00:00,temp_f:32.4 10