Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(snowflake): only compile sample to TABLESAMPLE on physical tables #10218

Merged
merged 1 commit into from
Sep 25, 2024

Conversation

jcrist
Copy link
Member

@jcrist jcrist commented Sep 25, 2024

In #10207 an xpassing test for snowflake was introduced. Instead of fixing the test marker, this expands our support for sample in snowflake by only compiling it to TABLESAMPLE on physical tables. Snowflake's TABLESAMPLE does work on subqueries, but only if method="row" and seed=None. At the physical plan this should be identical to filter with random; I don't anticipate a perf difference here (and it's a lot easier to avoid adding a snowflake-specific rule to handle this case).

@github-actions github-actions bot added the tests Issues or PRs related to tests label Sep 25, 2024
pytest.mark.notimpl(
["snowflake"],
raises=SnowflakeProgrammingError,
reason="SAMPLE clause on views only supports row wise sampling without seed.",
Copy link
Member Author

Choose a reason for hiding this comment

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

This error message was a bit confusing to me. I initially thought it was saying "SAMPLE on subqueries with no seed only works row wise" (implying that if a seed was set, then block wise would work), but actualy it means "SAMPLE on subqueries only works row wise with no seed"

@jcrist jcrist added snowflake The Snowflake backend ci-run-cloud Add this label to trigger a run of BigQuery, Snowflake, and Databricks backends in CI labels Sep 25, 2024
@ibis-docs-bot ibis-docs-bot bot removed the ci-run-cloud Add this label to trigger a run of BigQuery, Snowflake, and Databricks backends in CI label Sep 25, 2024
# Snowflake's TABLESAMPLE _can_ work on subqueries, but only by row and without
# a seed. This is effectively the same as `t.filter(random() <= fraction)`, and
# using TABLESAMPLE here would almost certainly have no benefit over the filter
# version in the optimized physical plan. To avoid a special case just for
Copy link
Member

Choose a reason for hiding this comment

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

Just curious, what is the special case here?

@cpcloud cpcloud added this to the 10.0 milestone Sep 25, 2024
@cpcloud cpcloud merged commit bdb718d into ibis-project:main Sep 25, 2024
85 checks passed
@jcrist jcrist deleted the fix-snowflake-sample branch September 25, 2024 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
snowflake The Snowflake backend tests Issues or PRs related to tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants