-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[CT-636] [Bug] Postgres unlimited varchar default to varchar(256) #5238
Comments
Yes! Very relevant: dbt-labs/dbt-utils#586 |
Seems really nice ! |
Ah, I see what you mean! In this logic: dbt-core/core/dbt/adapters/base/column.py Lines 85 to 93 in 0d8e061
You're saying, on Postgres, it actually should be allowed to remain I think this may also be a place where the behavior differs between Postgres + Redshift. On Redshift,
It's totally appropriate to implement different logic for |
As I could see Postgres already have a different way of handling TEXT columns and supersedes its parent in this case here : dbt-core/plugins/postgres/dbt/adapters/postgres/relation.py Lines 26 to 32 in 0d8e061
Also, for postgres, max varchar size is 10485760 as stated here, but only when explicitely stated (if not, it's actually the limit for any column of 1Gb). My guess is that it would be okay / accurate to also handle unlimited varchar the same way TEXT is handled in postgres, since i don't think the 256 default for postgres is the intended behaviour I'll be glad to submit a pr for this point if it seems legitimate |
You're so right!! Sorry I missed that. I think adding a new method to |
Is there an existing issue for this?
Current Behavior
When using postgres adapter with some varchar typed columns (like when using dbt_utils.type_string()), if you use incremental materialization with sync_new_columns or append_new_columns, or actually anything that will make dbt generate DDL statements, varchars max size defaults to 256 (handler in base/Column.py behaviour when char_size is None). This makes schema evolution impossible when having textual columns defined as {{ dbt_utils.type_string() }}
Expected Behavior
The original varchar type with no limit should remain as is and not be assigned a 256 default limit, because we don't know the size limit on a varchar without explicit limits. The schema evolution should be possible, with new columns not created as varchar(256)
Steps To Reproduce
Relevant log output
Error: `value too long for type character varying(256)`
Environment
What database are you using dbt with?
postgres
Additional Context
I already found out why it worked like that, and if validated will be happy to submit a PR (linked to the fact that the way postgres columns are retrieved have NULL info regarding varchar columns max_length, and thus when using it it falls back in default Column handler)
Just wondered if this shall be fixed in the PostgresColumn class (that already handles text columns this way), or if we shall just update the dbt_utils.string_type macro to use text instead of varchar for postgres
The text was updated successfully, but these errors were encountered: