Skip to main content Link Menu Expand (external link) Document Search Copy Copied

TUPLE() function

TUPLE() is a mathematical function that returns an ordered list of values corresponding to and derived from a supplied argument.

It is especially important for use in BULK INSERT statements to combine values intended for SETQ columns.

Before you begin

Syntax

TUPLE ([@<map-position>,...] | [<column-name>,... ])

Arguments

Argument Description Required Additional information
@<map-position>,... Used with BULK INSERT statements in the TRANSFORM clause to combine two or more values represented in the MAP clause   BULK INSERT…MAP
<column-name>,... Used in a SELECT statement to combine values from one or more columns in a given table    

Returns

Data type Value
TUPLE tuple with an element per evaluated expression (eval_expr1,eval_expr2,...)
Source data type Returns
IDSETQ TIMESTAMP and associated integer value
STRINGSETQ TIMESTAMP and associated string value

Examples

Source table tuple-demo

CREATE TABLE IF NOT EXISTS tuple-demo (
    _id STRING,
    time_col TIMESTAMP,
    stringset_col STRINGSET,
    idset_col IDSET,
    stringsetq_col STRINGSETQ timequantum 'YMD',
    idesetq_col IDSETQ timequantum 'Y'
);

BULK INSERT statement with TUPLE()

BULK INSERT INTO tuple-demo(
    _id,
    time_col,
    stringset_col,
    idset_col,
    stringsetq_col,
    idesetq_col
  )
  MAP (
    0 STRING,
    1 TIMESTAMP,
    2 STRINGSET,
    3 IDSET
  )
  TRANSFORM(
    @0,
    @1,
    @2,
    @3,
    TUPLE(@1,@2),
    TUPLE(@1,@3)
  )
  FROM x'
    A,2013-07-15T01:18:46Z,stringset1, 1
    B,2014-07-15T01:18:46Z,stringset2, 2
  '
  WITH
    BATCHSIZE 10000
    format 'CSV'
    input 'INLINE';

SELECT statement with TUPLE()

SELECT _id, TUPLE(time_col, stringset_col, idset_col)
  AS tup
  FROM tuple-demo;

_id | tup
----+-------------------------------------
  A | (2013-07-15T01:18:46Z,stringset1, 1)
  B | (2014-07-15T01:18:46Z,stringset2, 2)