dataengref migrate

Home / Teradata

Teradata SAMPLE in Snowflake, Databricks and BigQuery

Teradata SAMPLE takes a row count or a fraction. Snowflake SAMPLE and Databricks TABLESAMPLE accept both rows and percentages; BigQuery TABLESAMPLE only samples a percentage of storage blocks.

Teradata syntax: SELECT ... SAMPLE { n | fraction } [, ...] · Teradata docs

Equivalents

TargetSupportSyntaxNotesSource
SnowflakeRewriteSAMPLE (n ROWS) / SAMPLE (percent)The number without ROWS is a percentage, not a fraction.Snowflake docs
DatabricksRewriteTABLESAMPLE (n ROWS) / TABLESAMPLE (percent PERCENT)REPEATABLE (seed) makes the sample repeatable.Databricks docs
BigQueryRewriteTABLESAMPLE SYSTEM (percent PERCENT)Samples blocks, not rows. For an exact row count use ORDER BY RAND() LIMIT n.BigQuery docs

Behavior differences to check

Examples

Pick 1,000 random customers

Teradata
SELECT * FROM customers SAMPLE 1000;
Snowflake
SELECT * FROM customers SAMPLE (1000 ROWS);
Databricks
SELECT * FROM customers TABLESAMPLE (1000 ROWS);
BigQuery
SELECT * FROM customers ORDER BY RAND() LIMIT 1000;

Other Teradata functions

Last checked: · Paste a whole query into the SQL checker to find every function that needs a change.