Skip to content

Snowflake: add order_by_keys config #971

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

gwerbin-tive
Copy link

@gwerbin-tive gwerbin-tive commented Apr 3, 2025

This supports custom ordering, which might help with downstream query optimization in some cases.

For example, you could cluster on columns (a,b) and order by (a,c), or (a,b,c).

resolves #735 (ADAP-548)

Problem

Setting cluster_by_keys also forces an order by using the same columns. This is not always desirable.

Solution

Add a new config to control clustering and ordering separately. The user can explicitly pass order_by_keys=none to disable the default behavior, or pass a column name (or list of column names) to order by some other set of columns.

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX

@gwerbin-tive gwerbin-tive requested a review from a team as a code owner April 3, 2025 16:35
Copy link

cla-bot bot commented Apr 3, 2025

Thanks for your pull request, and welcome to our community! We require contributors to sign our Contributor License Agreement and we don't seem to have your signature on file. Check out this article for more information on why we have a CLA.

In order for us to review and merge your code, please submit the Individual Contributor License Agreement form attached above above. If you have questions about the CLA, or if you believe you've received this message in error, please reach out through a comment on this PR.

CLA has not been signed by users: @gwerbin-tive

Copy link
Contributor

github-actions bot commented Apr 3, 2025

Thank you for your pull request! We could not find a changelog entry for this change in the dbt-snowflake package. For details on how to document a change, see the Contributing Guide.

@dbeatty10
Copy link
Contributor

@gwerbin-tive Could you sign our Contributor License Agreement (if you haven't already)? Background here.

@cla-bot cla-bot bot added the cla:yes The PR author has signed the CLA label Apr 4, 2025
@gwerbin-tive
Copy link
Author

BTW I'd appreciate advice on getting started with testing in the dbt-adapters repo. We don't write many custom macros at Tive and we don't have a formal testing process for the few that we do have, which are usually less complicated than this.

gwerbin-tive and others added 4 commits April 7, 2025 10:38
This supports custom ordering, which might help with downstream query optimization in some cases.

For example, you could cluster on columns (a,b) and order by (a,c), or (a,b,c).
@gwerbin-tive gwerbin-tive force-pushed the snowflake-add-orderby-config branch from fe8691d to 142c988 Compare April 7, 2025 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes The PR author has signed the CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ADAP-548] [Feature] Flag to opt out of order by when cluster keys are specified
2 participants