Improve dbt seed times by removing type lookup and casting during INSERT #493
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #476
Description
Several users have noticed slow run times for loading dbt seeds with >1k records when using the
dbt-databricks
adapter, with run times becoming prohibitively slow for seeds with >10k records. This PR speeds up that run time substantially by removing unnecessary type lookup and casting during theINSERT
statement.DBT seeds essentially are built in two steps:
CREATE TABLE AS ...
INSERT OVERWRITE INTO table.schema VALUES ...
For some reason in the second step, there is both a type lookup and subsequent
CAST(x) AS type
for every single value (rows x columns) in the seed. This is effectively redundant and unnecessary, since the type information was already used when defining the column types during table creation.Removing these steps significantly speeds up the seed run times. For example, I was able to load a seed with 47k records and 9 columns in about 1 minute with this change, whereas previously the seed hadn't even finished after 10+ minutes of loading.
Checklist
CHANGELOG.md
and added information about my change to the "dbt-databricks next" section.