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

[Feature] postgres__get_columns_in_relation should support materialized views #124

Open
3 tasks done
adase11 opened this issue Jul 8, 2024 · 4 comments
Open
3 tasks done
Labels
enhancement New feature or request

Comments

@adase11
Copy link

adase11 commented Jul 8, 2024

Is this your first time submitting a feature request?

  • I have read the expectations for open source contributors
  • I have searched the existing issues, and I could not find an existing issue for this feature
  • I am requesting a straightforward extension of existing dbt-postgres functionality, rather than a Big Idea better suited to a discussion

Describe the feature

The macro postgres__get_columns_in_relation (link) only looks at the information_schema.columns to get the column names for the particular relation. This doesn't work for materialized views because information_schema.columns doesn't include information about materialized views. I think that adaptor macro could be enhanced to account for this and potentially look at pg_attribute (docs) instead. Based on this Stack Overflow it looks like its possible. I'm happy to research some more if that's helpful.

Describe alternatives you've considered

I considered reporting this as a bug but I think its more of a feature request. I imagine the information schema choice was intentional and maybe there is something I'm not considering about pg_attribute that you all have already considered that makes it unfeasible. In that case I'd propose documenting this nuance for postgres.

Who will this benefit?

Anyone using the dbt_utils.star macro with postgres (like I was)

Are you interested in contributing this feature?

I'm happy to contribute if this request is accepted

Anything else?

No response

@adase11 adase11 added enhancement New feature or request triage labels Jul 8, 2024
@drewblinn
Copy link

Does this solution help you @adase11?
dbt-labs/dbt-codegen#155
dbt-labs/dbt-core#9419

@adase11
Copy link
Author

adase11 commented Jul 15, 2024

@drewblinn it looks like yes. The implementation of the PR I didn't fully check, but I can look to see if it will cover what I'm looking for (it looks like it intends to). The way I went about it for my custom macro was that I queried the information schema for non-materialized views and pg_attribute only for MVs.

@adase11
Copy link
Author

adase11 commented Jul 16, 2024

Double checked, the PR looks right to me. Although it looks like that was aimed at dbt-core and the adaptors have been decoupled from dbt-core and so those changes would be better served in this module (dbt-postgres).

@drewblinn
Copy link

I also overrode it in our project, but I'll get a PR together to roll these changes out to dbt-postgres the the entire community can reap the benefits! @adase11

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

No branches or pull requests

3 participants