Skip to content

Support TABLESAMPLE RESERVOIR - #2898

Open
abdolence wants to merge 2 commits into
apache:mainfrom
abdolence:tablesample-reservoir
Open

abdolence wants to merge 2 commits into
apache:mainfrom
abdolence:tablesample-reservoir

Conversation

@abdolence

Copy link
Copy Markdown

SELECT * FROM t TABLESAMPLE RESERVOIR (100 ROWS) fails with Expected: end of statement, found: (.

GoogleSQL has RESERVOIR beside BERNOULLI as a TABLESAMPLE method that samples a fixed number of rows. Spanner runs it (docs). This adds the RESERVOIR keyword and TableSampleMethod::Reservoir. Like the other methods, it is not gated on a dialect.

  • RESERVOIR is not reserved, so reservoir still works as a column name and as a table alias;
  • BigQuery accepts any method name when parsing, then runs only SYSTEM;
  • PARTITION BY inside the parentheses and WITH WEIGHT from the same grammar are not covered here.

Dialects: BigQuery

Comment thread src/ast/query.rs
System,
/// `BLOCK` sampling method.
Block,
/// `RESERVOIR` sampling method.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a documentation link here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, added a link to the docs and short description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants