Skip to content

fix: execute INSERTs with fetch=false - #1049

Open
github-christophe-oudar wants to merge 2 commits into
elementary-data:masterfrom
github-christophe-oudar:fix/execute-inserts-without-fetch
Open

fix: execute INSERTs with fetch=false#1049
github-christophe-oudar wants to merge 2 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

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-core#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 internal data insertion operations by avoiding unnecessary result-set retrieval.
    • Enhanced reliability and efficiency when recording metrics and schema snapshots.
    • Maintained query metadata formatting while executing background insert operations.

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: 6c6f3fb7-48dd-46d9-abef-b075c8d48be8

📥 Commits

Reviewing files that changed from the base of the PR and between 6184061 and e3c64f1.

📒 Files selected for processing (3)
  • macros/edr/tests/on_run_end/handle_tests_results.sql
  • macros/utils/run_queries/run_query.sql
  • 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 e3c64

The change only adjusts INSERT execution to avoid fetching unused results, with no actionable merge-blocking risk remaining after normal checks and review.

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: INSERT statements now execute with fetch=false instead of fetching discarded results.
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.
Full details: Docstring Coverage

Explanation

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 files. (3 skipped: 3 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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