table_sort

A stable sort by keys, directions and null placement.

ConstructDeterministic

Flags

Flag Value
Kind construct: makes a value from values
Rows keeps the rows
Deterministic yes
Order matters no
Decomposable yes, by sorted runs, merged in chunk order
Makes a table value

Parameters

Parameter Type Required Notes
table reference yes A value's reference.
keys array of sort_key no The keys, most significant first; nulls last unless asked.
response_format "concise" | "detailed" no The byte budget: 64 KiB concise, 512 KiB detailed.

Example

Over the example tables trades; ${input:name} is an input's reference and ${verb} the value an earlier call made.

JSON
table_sort {
  "table": "${input:trades}",
  "keys": [
    {
      "expr": {
        "col": 1
      }
    }
  ]
}

Result

70 rows

JSON
{
  "ref": "sha256:6157690d0785a20fb36f6c147260170b082b2e8662715b2210c8ef4fea17d443",
  "kind": "table",
  "rows": 70,
  "schema": {
    "fields": [
      {
        "name": "sym",
        "type": {
          "kind": "utf8"
        },
        "nullable": false,
        "metadata": {}
      },
      {
        "name": "tat",
        "type": {
          "kind": "timestamp",
          "zone": "UTC"
        },
        "nullable": false,
        "metadata": {}
      },
      {
        "name": "qty",
        "type": {
          "kind": "int64"
        },
        "nullable": false,
        "metadata": {}
      }
    ],
    "metadata": {}
  }
}

In the hint language

The same step as a plan, as the language prints it.

Hint
output out = from trades
sort {tat}

Diagnostics

A refusal comes back as ok: false with coded diagnostics; every code, with its fix, is on the diagnostics page. A parameter that does not match the schema above is ARG_INVALID, with the parameter's path.