surfacepipelinesample
Pipelinepipeline · returns table

SAMPLE

Take a random sample of rows

Table-in, table-out — composes downstream of SELECTs.

pipelinellmpipeline-composabletext

Syntax

THEN SAMPLE
THEN SAMPLE {{ n }}
THEN SAMPLE({{ n }})

Arguments

nametypedescription
n(optional)VARCHAR
_tableTABLE

About

PIPELINE cascade for random sampling. Uses pure Python/pandas - no LLM calls. Usage: SELECT * FROM big_table THEN SAMPLE -- default 10 rows SELECT * FROM big_table THEN SAMPLE(100) -- 100 rows SELECT * FROM big_table THEN SAMPLE('0.1') -- 10% of rows

Examples

Returns the requested sample size

SELECT
  *
FROM
  (
    VALUES
      (1),
      (2),
      (3),
      (4)
  ) AS t (x) THEN SAMPLE (2) THEN PYTHON ('result = pd.DataFrame({"row_count":[len(df)]})')

Nearby rabbit holes

same domain
Climb back to The Looking Glass