question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Relation name '*__dbt_tmp' is longer than 63 characters

See original GitHub issue

Describe the bug

My view name is pretty long, but it is less than 63 characters.

When dbt adds the __dbt_tmp suffix, it goes over the limit of 63 chars.

The following error is thrown by PostgreSQL:

Relation name ‘foo__dbt_tmp’ is longer than 63 characters

Steps To Reproduce

  1. Use a view name that is 63 characters long.
  2. dbt run

Expected behavior

To work anyways.

Screenshots and log output

See above.

System information

Which database are you using dbt with?

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

The output of dbt --version:

Using Docker image fishtownanalytics/dbt:0.18.1.

The operating system you’re using:

Using Docker image fishtownanalytics/dbt:0.18.1.

The output of python --version:

Using Docker image fishtownanalytics/dbt:0.18.1.

Additional context

Perhaps the temporary name can be truncated by the length of the suffix to make sure it fits within the limits?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
danielefrigocommented, Jun 28, 2021

Thanks for opening, @moltar! I agree, this is peskier than it could be.

Following the discussion about this over in #2850, the real max character length of a model name on Postgres is currently 51, because of the appended suffix __dbt_backup in the table and view materializations.

I think we could do as you recommend, and truncate the model name (if >51 characters) to accommodate the suffix. I view that as a reasonable next step on top of the work in #2850, which handles the truncation of uniquely suffixed identifiers in the incremental materialization.

Regarding the proposal of truncating the model name, I see a potential overlapping issue: you could have 2 models running in parallel, with a long common prefix in the name. If we truncate the model name, the tmp tables created by dbt could end up having exactly the same name. An alternative could be to completely loose the name link between the model name and the temp table name, using some kind of unique short identifier (e.g. an hash of the model name).

1reaction
jtcohen6commented, Jun 28, 2021

@danielefrigo A hash of the model name makes a lot of sense to me! I’d still like to keep the conventional suffixes (__dbt_backup, __dbt_tmp) as well, for clarity of ownership.

Read more comments on GitHub >

github_iconTop Results From Across the Web

variable name length exceeds 63 characters - MATLAB Answers
Your demand for more than 63 characters sounds, like you store important values in the name instead of the contents of a variable....
Read more >
PostgreSQL's Max Identifier Length Is 63 Bytes
Postgres warns us of identifiers longer than 63 characters, informing us of what they will be truncated to. It then proceeds to create...
Read more >
Index name "index_name" is too long; the limit is 63 characters
The system uses no more than NAMEDATALEN-1 bytes of an identifier; longer names can be written in commands, but they will be truncated....
Read more >
CUY-90-14.90
Enhanced structural durability for longer service life. A progressive approach to storm water management and best management practices (BMPs).
Read more >
Make sure that the identifiers are not more the 63 characters ...
+ * PostgreSQL allows in standard configuration no longer identifiers than 63 + * chars for table/relation names, indexes, primary keys, and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found