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

Add an optional name field for the Postgres adapter indexes configurations #8999

Conversation

nazliander
Copy link

@nazliander nazliander commented Nov 4, 2023

resolves dbt-labs/dbt-postgres#52

Problem

Currently Postgres Adapter does not accept a name field in the model indexes configurations. This might be unnecessary for some of the users. But for readability and maintenance, a meaningful index name can be helpful. As I understood from the previous threads this is mainly due to the need of unique names of indices within a transaction. I did not test or understood fully what is breaking. However, I wanted to follow the following threads and keep the original idea of uniqueness. So developed a solution bearing this in mind.

Solution

Adding an optional name field in the Postgres Index Config. If the name is not provided the index name will be an MD5 hash of the index config contents as it was previously. If the name is provided then the Unix Time of the index creation will be concatenated to the name provided. This way we will have the benefit of both uniqueness and the semantics.

I also edited the relevant tests. This is my first time contribution attempt. Please let me know if there is something over or under developed. Happy to help.

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
  • This PR includes type annotations for new and modified functions

@nazliander nazliander requested review from a team as code owners November 4, 2023 20:25
Copy link

cla-bot bot commented Nov 4, 2023

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: @nazliander

Copy link
Contributor

github-actions bot commented Nov 4, 2023

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@nazliander nazliander force-pushed the feat/8580-ability-to-define-semantic-names-on-postgres-adapter branch from 4469af9 to e97bb6d Compare November 4, 2023 20:37
@cla-bot cla-bot bot added the cla:yes label Nov 4, 2023
@nazliander nazliander changed the title Add an optional name field of the Postgres adapter indexes configurations Add an optional name field for the Postgres adapter indexes configurations Nov 4, 2023
@dbeatty10 dbeatty10 added the community This PR is from a community member label Mar 22, 2024
@dbeatty10 dbeatty10 added Team:Adapters Issues designated for the adapter area of the code dbt-postgres Needs migration to dbt-postgres repo enhancement New feature or request labels Apr 9, 2024
@dbeatty10
Copy link
Contributor

Thanks for taking the time to open this PR @nazliander! Since opening, we've decoupled dbt Adapters from dbt Core, and this code now lives in a separate repo: dbt-postgres.

A consequence of the decoupling is that PR can't be merged anymore as is, so we're closing it. For more context see #9171.

The linked issue has already been transferred. Please don't hesitate to re-open your proposed code changes within this PR in the dbt-postgres repo.

@dbeatty10 dbeatty10 closed this Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes community This PR is from a community member dbt-postgres Needs migration to dbt-postgres repo enhancement New feature or request Team:Adapters Issues designated for the adapter area of the code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CT-3086] [Feature] Add "name" to Postgres index configuration
2 participants