Skip to content

fix(teradata): transpile SAMPLE row counts and fractions [CLAUDE] - #8670

Merged
georgesittas merged 1 commit into
tobymao:mainfrom
bhuvan-uda:teradata-sample-clause
Oct 19, 2026
Merged

georgesittas merged 1 commit into
tobymao:mainfrom
bhuvan-uda:teradata-sample-clause

Conversation

@bhuvan-uda

Copy link
Copy Markdown
Contributor

Closes #8669

The Teradata parser kept the SAMPLE value in TableSample.expressions, which only the Teradata generator reads, so other dialects produced an empty TABLESAMPLE ().

TeradataParser._parse_table_sample now maps a single integer to size (row count) and a single fraction to percent. For example, SAMPLE 0.25 becomes Snowflake TABLESAMPLE (25) and DuckDB TABLESAMPLE (25 PERCENT). The Teradata generator converts percent back to a fraction, so round trips stay the same. SAMPLE 1.00 keeps its decimal point so it isn't read back as a row count.

Multiple sample sets (SAMPLE 0.6, 0.25) return disjoint samples in Teradata and have no equivalent elsewhere. The base generator now drops them with an unsupported warning instead of emitting TABLESAMPLE ().

Tests: added cases to TestTeradata.test_teradata. I also ran the DuckDB output against DuckDB. The full unit suite (SKIP_INTEGRATION=1 python -m unittest) passes.

I used Claude Code to write this change and reviewed it myself.

🤖 Generated with Claude Code

Teradata's SAMPLE clause was always stored as a list of expressions, which
other dialects can't generate, so it became an empty `TABLESAMPLE ()`. A
single integer sample is now parsed as a row count (size) and a single
fraction as a percentage, e.g. SAMPLE 0.25 -> Snowflake TABLESAMPLE (25).
Multiple sample sets have no equivalent, so they're dropped with an
unsupported warning.

Closes tobymao#8669

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@georgesittas
georgesittas merged commit f8c314c into tobymao:main Oct 19, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Teradata: SAMPLE clause is transpiled to an empty TABLESAMPLE ()

2 participants