Skip to content

fix: execute INSERTs with fetch=false - #1049

Merged
haritamar merged 4 commits into
elementary-data:masterfrom
github-christophe-oudar:fix/execute-inserts-without-fetch
Sep 7, 2026
Merged

fix: execute INSERTs with fetch=false#1049
haritamar merged 4 commits into
elementary-data:masterfrom
github-christophe-oudar:fix/execute-inserts-without-fetch

Conversation

@github-christophe-oudar

@github-christophe-oudar github-christophe-oudar commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add elementary.execute_no_fetch, which calls adapter.execute(..., fetch=false) after the usual metadata comment wrapping.
  • Switch insert_rows and the on-run-end test-result INSERTs in handle_tests_results to that helper instead of dbt.run_query.

Why

Callers already discarded INSERT results. dbt.run_query always fetches (statement(..., fetch_result=true)).

adapter.execute(sql, fetch=false) is the existing dbt adapter API (fetch=False is the default on dbt-core 1.x). This is not a Fusion-only flag and should not change 1.x behavior: run the INSERT, do not materialize a result table.

On Fusion this becomes effective once dbt-labs/dbt-oss#16064 lands (Fusion currently still drains the Arrow reader on BigQuery even when fetch=false).

Test plan

  • dbt run / dbt test with Elementary enabled
  • Confirm on-run-end still writes run/test results

Summary by CodeRabbit

  • Bug Fixes
    • Improved background data recording by avoiding unnecessary retrieval of query results.
    • Enhanced efficiency when saving metrics, schema snapshots, test results, and other generated records.
    • Preserved metadata formatting during background insert operations.
    • Reduced processing overhead during automated test-result handling and routine data updates.
    • Improved reliability for operations that record generated results without requiring returned query data.

Kayrnt added 2 commits August 24, 2026 00:51
…torage-Read destination tables

dbt.run_query always fetches results. Fusion's BigQuery path then reads the job destination table, which OOMs on large elementary tables during on-run-end. Callers already discarded those INSERT results.
…se-specific fetch bug

Callers that ignore INSERT results should not use run_query, which always fetches.
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

👋 @github-christophe-oudar
Thank you for raising your pull request.
Please make sure to add tests and document all user-facing changes.
You can do this by editing the docs files in the elementary repository.

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 0800917f-972d-4cc6-b9e0-1e5cf3db2f7d

📥 Commits

Reviewing files that changed from the base of the PR and between 17b0909 and 896525d.

📒 Files selected for processing (1)
  • macros/utils/table_operations/insert_rows.sql

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The change adds execute_no_fetch for adapter execution without result fetching. Metrics, schema snapshot, and row insertion macros now use it instead of run_query.

Changes

Query execution

Layer / File(s) Summary
Add non-fetching execution helper
macros/utils/run_queries/run_query.sql
Adds execute_no_fetch, which formats the query and calls adapter.execute with fetch=false.
Migrate insert operations
macros/edr/tests/on_run_end/handle_tests_results.sql, macros/utils/table_operations/insert_rows.sql
Generated metrics, schema snapshot, and row insert statements now use execute_no_fetch.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 89652

INSERT operations now avoid fetching discarded result tables while preserving their execution flow. No current merge-readiness risk is identified.

Suggested reviewers: haritamar

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: executing INSERT statements with fetch=false.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@haritamar
haritamar deployed to elementary_test_env September 6, 2026 21:09 — with GitHub Actions Active
@haritamar
haritamar deployed to elementary_test_env September 7, 2026 07:30 — with GitHub Actions Active
@haritamar
haritamar merged commit 4c98e08 into elementary-data:master Sep 7, 2026
29 checks passed
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.

3 participants