Skip to main content
Version: v4.22

select

Selects some values and discards the rest.

select (field|assignment)...

Description

This operator keeps only the provided fields and drops the rest.

field

The field to keep. If it does not exist, it's given the value null and a warning is emitted.

assignment

An assignment of the form <field>=<expr>.

Examples

Keep a and introduce y with the value of b:

from {a: 1, b: 2, c: 3}
select a, y=b
―――――――――――――――――――――――
{a: 1, y: 2}

A more complex example with expressions and selection through records:

from {
  name: "foo",
  pos: {
    x: 1,
    y: 2,
  },
  state: "active",
}
select id=name.to_upper(), pos.x, added=true
――――――――――――――――――――――――――――――――――――――――――――
{
  id: "FOO",
  pos: {
    x: 1,
  },
  added: true,
}