table_sample

A seeded sample by fraction or count.

ConstructDeterministic

Flags

Flag Value
Kind construct: makes a value from values
Rows keeps some rows
Deterministic yes
Order matters yes
Decomposable no
Makes a table value

Parameters

Parameter Type Required Notes
table reference yes A value's reference.
fraction number no at least 0, at most 1. The probability of each row (Bernoulli); give this or count.
count integer no at least 0. Exactly this many rows, or all when fewer (reservoir); give this or fraction.
seed integer yes at least 0. The seed; nothing is random by default.
response_format "concise" | "detailed" no The byte budget: 64 KiB concise, 512 KiB detailed.

Example

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

JSON
table_sample {
  "table": "${input:orders}",
  "count": 10,
  "seed": 8
}

Result

10 rows

JSON
{
  "ref": "sha256:a27b61c612c5e695f594c5ad15737ef0282747c7ee93f7d1f551dabf5a2f403c",
  "kind": "table",
  "rows": 10,
  "schema": "…"
}

In the hint language

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

Hint
output out = from orders
sample 10 seed:8

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.