Skip to content

perf: resolve seed placeholder and cast types once per load - #1722

Merged
sd-db merged 6 commits into
mainfrom
sd-db/perf/seed-load-csv-rows-resolve-once
Nov 2, 2026
Merged

sd-db merged 6 commits into
mainfrom
sd-db/perf/seed-load-csv-rows-resolve-once

Conversation

@sd-db

@sd-db sd-db commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Resolves #

Description

databricks__load_csv_rows rendered get_binding_char() once per cell and, for file_format: parquet
seeds, called adapter.convert_type once per cell. Neither value depends on the row, so a
10,000-row × 80-column seed made 800,000 calls of each just to build the same SQL. This resolves the
placeholder once per load and the cast types (including column_types overrides) once per column.
get_binding_char() still goes through dispatch, so a project-level override keeps working. The SQL
sent to Databricks is unchanged.

The same loop made dbt seeds hang in the Fusion engine (dbt-labs/dbt#16748); this is the v1 version
of that fix.

Measured on a serverless SQL warehouse with a 10,000 × 80 seed:

Seed Before After
Delta 197.6s, 199.0s 45.2s
Parquet (Hive metastore) 2902s, then Query text size exceeds limit 13.2s to the same error

Stock and patched delta loads produce identical tables: same row count, content hash, and column
types. The parquet error happens at the warehouse with or without this change: at the default
10,000-row batch size, a wide parquet seed's single insert is too long. A 1,000-row batch loads the
patched parquet seed in 87.5s. Batch sizing is not changed here.

Checklist

  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • I have updated the CHANGELOG.md and added information about my change to the "dbt-databricks next" section.
  • [Optional] I have run the dbt-databricks-pr-ready project skill for this PR and addressed its merge-readiness feedback

Tests: new tests/unit/macros/materializations/test_seed_macros.py pins the generated SQL and fails
on the old macro's per-cell convert_type calls; tests/unit/macros (333) and
tests/functional/adapter/simple_seed on databricks_uc_sql_endpoint (19) pass.

This pull request and its description were written by Isaac.

sd-db added a commit that referenced this pull request Oct 15, 2026
Co-authored-by: Isaac <no-reply@databricks.com>
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Coverage report

This PR does not seem to contain any modification to coverable code.

Base automatically changed from 1.13.latest to main October 28, 2026 05:11
sd-db and others added 2 commits October 28, 2026 11:57
databricks__load_csv_rows rendered get_binding_char() for every cell and, for parquet seeds, called adapter.convert_type for every cell. Resolve the placeholder once per load and the cast types once per column. get_binding_char() still dispatches, so project overrides keep working. The generated SQL is unchanged.

Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
@sd-db
sd-db force-pushed the sd-db/perf/seed-load-csv-rows-resolve-once branch from 9795541 to 2deccf0 Compare October 28, 2026 06:52
@sd-db
sd-db merged commit bb29f51 into main Nov 2, 2026
9 checks passed
@sd-db
sd-db deleted the sd-db/perf/seed-load-csv-rows-resolve-once branch November 2, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants