redshift_admin_table_stats.is_encoded is always true
- Dominant language
- PLpgSQL
- Stars
- 105
- Forks
- 39
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the bug
From my understanding, field `is_encoded` from model `redshift_admin_table_stats` should indicate whether the table we're looking at has at least one encoded column. But currently the field is computed by looking in `pg_attribute` if any table attribute is encoded. The result is that if at least one attribute is encoded, the table appears as having at least one column encoded. Worse: in our redshift, the `tableoid` attribute is almost always encoded. Hence all tables have their `is_encoded` field set to true.
### Steps to reproduce
Run the following in your redshift:
```
select attencodingtype, count(1)
from pg_attribute
where attname = 'tableoid'
group by 1;
```
And the following:
```
select is_encoded count(1)
from redshift_admin_table_stats
group by 1;
```
### Expected results
We have some tables for which no column is encoded. They should appear when running the above query.
### Actual results
In `redshift_admin_table_stats`, the tables I just mentioned are flagged as `is_encoded`, which should not be the case.
### System information
**The contents of your `packages.yml` file:**
```
packages:
- package: fishtown-analytics/dbt_utils
version: 0.6.3
- package: fishtown-analytics/redshift
version: 0.4.1
- package: fivetran/jira_source
version: [">=0.1.0","<0.2.0"]
- package: fivetran/jira
version: 0.1.5
- package: fivetran/intercom_source
version: 0.1.2
- package: fivetran/intercom
version: 0.1.2
```
**Which database are you using dbt with?**
- [ ] postgres
- [x] redshift
- [ ] bigquery
- [ ] snowflake
- [ ] other (specify: ____________)
**The output of `dbt --version`:**
```
installed version: 0.18.0
latest version: 0.19.1
Your version of dbt is out of date! You can find instructions for upgrading here:
https://docs.getdbt.com/docs/installation
Plugins:
- bigquery: 0.18.0
- snowflake: 0.18.0
- redshift: 0.18.0
- postgres: 0.18.0
```
**The operating system you're using:**
OSX 11.2.3
**The output of `python --version`:**
Python 3.6.8
### Additional context
Willing to open a PR if you confirm this should be the desired behavior. From what I understand we just need to restrict the `max(attencodingtype)` to attributes that have a strictly positive `attnum`?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.