Repository navigation
fix(teradata): transpile SAMPLE row counts and fractions [CLAUDE] - #8670
Merged
Merged
Conversation
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
approved these changes
Oct 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #8669
The Teradata parser kept the SAMPLE value in
TableSample.expressions, which only the Teradata generator reads, so other dialects produced an emptyTABLESAMPLE ().TeradataParser._parse_table_samplenow maps a single integer tosize(row count) and a single fraction topercent. For example,SAMPLE 0.25becomes SnowflakeTABLESAMPLE (25)and DuckDBTABLESAMPLE (25 PERCENT). The Teradata generator convertspercentback to a fraction, so round trips stay the same.SAMPLE 1.00keeps 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 emittingTABLESAMPLE ().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