Work with composite data types.
x
, y
, … (any type): Values of any type.IN
clauses or as arguments for lambda functions. Tuples cannot be directly written to tables.
(x, y, ...)
, so you can also create tuples using parentheses:tuple
(Tuple
): The input tuple.index
(numeric): The 1-based index of the element to return.name
(String
): The name of the element to return.default_value
(optional): The value to return if the index is out of bounds or the name doesn’t exist.second_filling
returns the second element of the tuple.salsa_type
returns the value associated with the ‘salsa’ key in the named tuple.x.index
and x.name
for tuple access.x
(Tuple
): A tuple function, column, or tuple of elements.untuple
expands the items
tuple into separate columns.
Example using EXCEPT:
quantity
field from the result.
untuple
function is particularly useful when working with complex nested structures or when you need to flatten tuple data for further processing or analysis.tuple1
(Tuple
): First tuple.tuple2
(Tuple
): Second tuple.tuple
(Tuple
): A named tuple.Array(Tuple(String, T))
Example:
tuple
(Tuple
): A named tuple.Array(String)
.
Example:
tuple1
(Tuple
): First tuple.tuple2
(Tuple
): Second tuple.Tuple
).tuplePlus
adds the corresponding elements of two tuples:
tuple1
(Tuple
): First tuple.tuple2
(Tuple
): Second tuple.Tuple
)
Example:
tupleMinus
function performs element-wise subtraction, allowing for quick calculations on multiple values simultaneously.
Arguments:
tuple1
(Tuple
): First tuple.tuple2
(Tuple
): Second tuple.Tuple
).tuple1
(Tuple
): First tuple.tuple2
(Tuple
): Second tuple.Tuple
).inf
.tuple
(Tuple
): A tuple containing numeric values.Tuple
).
Example:
tupleNegate
calculates the negation of each value in the input tuple (1, 2, -3)
, resulting in (-1, -2, 3)
.
This function is useful when you need to invert the signs of all values in a tuple simultaneously, such as when working with coordinate systems or financial calculations involving debits and credits.
tupleNegate
function only works with tuples containing numeric values. Attempting to negate non-numeric values will result in an error.tuple
(Tuple
): A tuple containing numeric values.number
(numeric): The multiplier.Tuple
).(1, 2, 3)
is multiplied by 2
, resulting in a new tuple (2, 4, 6)
.
Example:
tuple
(Tuple
): A tuple containing numeric values.number
(numeric): The divisor.Tuple
).inf
.(10, 20, 30)
is divided by 5, resulting in the tuple (2, 4, 6)
.
Example:
taco_prices
tuple by 2.
tuple1
, tuple2
, … (Tuple
): Two or more tuples of any type.tupleConcat
combines three tuples: one with a number and a taco filling, another with a different number and filling, and a third with a boolean and a salsa type. The result is a single tuple containing all these elements.
This function is useful for combining data from different sources or for creating more complex tuple structures from simpler ones.
Syntax:
tuple_num
(Tuple
): Tuple of numerators. Tuple of numeric type.tuple_div
(Tuple
): Tuple of divisors. Tuple of numeric type.Tuple
of integer values.tuple_num
or tuple_div
contain non-integer values, the result is calculated by rounding to the nearest integer for each non-integer numerator or divisor.15 / 3 = 5
10 / 2 = 5
5 / 2 = 2
(integer division)tupleIntDiv
, this function returns 0 for division by zero instead of throwing an error.
Syntax:
tuple_num
(Tuple
): Tuple of numerators. Tuple of numeric type.tuple_div
(Tuple
): Tuple of divisors. Tuple of numeric type.Tuple
of integer values.tuple_num
or tuple_div
contain non-integer values, the result is calculated by rounding to the nearest integer for each non-integer numerator or divisor.15 / 3 = 5
10 / 0 = 0
(division by zero)5 / 2 = 2
(integer division)tuple_num
(Tuple
): Tuple of numerator values. Tuple of numeric type.div
(numeric): The divisor value. Numeric type.Tuple
of integer values.tuple_num
or div
contain non-integer values, the result is calculated by rounding to the nearest integer for each non-integer numerator or divisor.(15, 10, 5)
is divided by 3, resulting in (5, 3, 1)
.
Example:
tuple_num
(Tuple
): Tuple of numerator values. Tuple of numeric type.div
(numeric): The divisor value.tuple_num
and div
. Tuple
of integer values.tuple_num
or div
contain non-integer values, the result is calculated by rounding to the nearest integer for each non-integer numerator or divisor.tuple_num
(Tuple
): Tuple of numerator values. Tuple of numeric type.tuple_mod
(Tuple
): Tuple of modulus values. Tuple of numeric type.tuple_num
and tuple_mod
. Tuple
of non-zero integer values.tuple_num
(Tuple
): Tuple of numeric values.div
(numeric): The divisor value.Tuple
of numeric values.15 % 3 = 0
10 % 3 = 1
5 % 3 = 2
input
(Tuple
): A nested named tuple to flatten.Tuple
).
This function can be used to select all paths from a nested tuple as separate columns.
Example:
order
tuple is flattened into a single-level tuple, making it easier to access individual elements or use them in further calculations.