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

Enable cataloging unlogged postgres tables #3961

Closed
1 of 5 tasks
ollivierj opened this issue Sep 28, 2021 · 3 comments · Fixed by #3993
Closed
1 of 5 tasks

Enable cataloging unlogged postgres tables #3961

ollivierj opened this issue Sep 28, 2021 · 3 comments · Fixed by #3993
Labels
bug Something isn't working good_first_issue Straightforward + self-contained changes, good for new contributors! postgres

Comments

@ollivierj
Copy link

ollivierj commented Sep 28, 2021

Describe the bug

We use postgres 12.4.1 as a datawarehouse. During the ingestion processing, we use unlogged tables to speed up writing data into tables. Those tables are in a schema dedicated for storing raw data. We then transform this raw data using dbt.

We use the command below to generate the dbt documentation :

dbt docs generate --project-dir <MY_DBT_PROJECT> --profiles-dir <MY_PROFILE_DIR>

When looking at the dbt documentation, none of the unlogged tables have their columns information filled up.

We checked the dbt code source and found that dbt does ignore unlogged and temporary tables when getting columns information :
https://github.com/dbt-labs/dbt/blob/749f87397ec1e0a270b2e09bd8dbeb71862fdb81/plugins/postgres/dbt/include/postgres/macros/catalog.sql#L39

Steps To Reproduce

Create a postgres unlogged table, initialize a dbt project then run :

dbt docs generate

Expected behavior

In the dbt documentation, i can see postgres unlogged table columns information

Screenshots and log output

image

System information

Which database are you using dbt with?

  • postgres
  • redshift
  • bigquery
  • snowflake
  • other (specify: ____________)

The output of dbt --version:

installed version: 0.20.2
   latest version: 0.20.2

Up to date!

Plugins:
  - bigquery: 0.20.2
  - snowflake: 0.20.2
  - postgres: 0.20.2
  - redshift: 0.20.2

The operating system you're using:

PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian

The output of python --version:

Python 3.8.8

Additional context

Add any other context about the problem here.

@ollivierj ollivierj added bug Something isn't working triage labels Sep 28, 2021
@jtcohen6
Copy link
Contributor

@ollivierj Good call! It sounds like the fix here is really quite minor, by changing the linked line to:

      and tbl.relpersistence in ('p', 'u') -- [p]ermanent table or [u]nlogged table. Exclude [t]emporary tables

It doesn't look like we have any integration tests for the unlogged config, so now is as good a time as any to add one. I think this could be as simple as:

  • Defining a model with {{ config(materialized = 'table', unlogged=True) }}
  • Running it
  • Executing a query (or dbt test!) that hits pg_class to confirm that the table is indeed unlogged
  • Generating docs
  • Confirming that the table appears in catalog.json

Would you be interested in contributing that fix? :)

@jtcohen6 jtcohen6 added good_first_issue Straightforward + self-contained changes, good for new contributors! redshift postgres and removed triage redshift labels Sep 28, 2021
@ollivierj
Copy link
Author

@jtcohen6 Hi Jeremy,
Thank you for getting back to me.
I will be available from December 11st for working on this issue.

@jtcohen6
Copy link
Contributor

Sounds good! If someone else wishes to contribute the fix for this sooner, I'd welcome a PR for it.

samlader pushed a commit to samlader/dbt that referenced this issue Oct 3, 2021
jtcohen6 pushed a commit that referenced this issue Oct 6, 2021
* Update catalog macro & add tests

* [#3961] Enable cataloging of unlogged Postgres tables

* Update contributors and add new lines to test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good_first_issue Straightforward + self-contained changes, good for new contributors! postgres
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants