Tuples

Tuple is a container type, composed of multiple fields. Each field can have a different type. Number of fields and their types must be known at compile time.

Tuple is represented by {}. It can span multiple lines. Fields can be assigned a name. Fields are separated by commas, trailing trailing comma is optional.

  1. let var1 = {x = 1, y = 2}
  2. let var2 = { # Span multiple lines
  3. a = x,
  4. b = y # Optional trailing comma
  5. }
  6. let var3 = {
  7. c, # Individual item
  8. d = b, # Assignment
  9. }

Tuples are the type of a table row, which means that they are expected by many transforms. Most transforms can also take a single field, which will be converted into a tuple. These are equivalent:

PRQL

  1. from employees
  2. select {first_name}

SQL

  1. SELECT
  2. first_name
  3. FROM
  4. employees

PRQL

  1. from employees
  2. select first_name

SQL

  1. SELECT
  2. first_name
  3. FROM
  4. employees

Note

Prior to 0.9.0, tuples were previously named Lists, and represented with [] syntax. There may still be references to the old naming.