Skip to content
New issue

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

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

Already on GitHub? # to your account

Add rely option to primary key constraint #900

Open
mmansikka opened this issue Jan 10, 2025 · 1 comment
Open

Add rely option to primary key constraint #900

mmansikka opened this issue Jan 10, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@mmansikka
Copy link

Describe the feature

I would like an option to specify in the .yaml file if the primary key uses the rely option. Possible name for this could be rely or constraint_option. Rely would significantly speed up queries.

Describe alternatives you've considered

Manually changing the primary keys for tables gets overwritten by full-refresh deployments

Additional context

Docs for rely https://learn.microsoft.com/en-us/azure/databricks/sql/language-manual/sql-ref-syntax-ddl-create-table-constraint
Speeding up queries with rely https://learn.microsoft.com/en-us/azure/databricks/sql/user/queries/query-optimization-constraints
On databricks this blog post https://www.databricks.com/blog/primary-key-and-foreign-key-constraints-are-ga-and-now-enable-faster-queries

The change would be before this part of the code defining the alter table statement for primary key constraint

{% set stmt = "alter table " ~ relation ~ " add constraint " ~ name ~ " primary key(" ~ joined_names ~ ");" %}

Who will this benefit?

This will speed up user queries and make sure what is defined in dbt project is in line with UC table constraints.

Are you interested in contributing this feature?

I can write some code but new to developing this adapter

@mmansikka mmansikka added the enhancement New feature or request label Jan 10, 2025
@benc-db
Copy link
Collaborator

benc-db commented Jan 17, 2025

@mmansikka this is in the works and coming in dbt-databricks 1.10. Rather than enforce specific options via config, plan is to use the expression field to allow any additional config to PK/FK.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants