Repository navigation
CORE-1558: fix: run discard-result DDL/DML without fetching results - #1080
EladBarkay wants to merge 2 commits into
Conversation
On Spark 3.5 with dbt-spark's thrift method, the thrift server returns no row set for CREATE TABLE AS / INSERT results, and PyHive's fetchall() raises "'NoneType' object is not iterable". elementary.run_query wraps dbt.run_query, which always fetches, so every artifact model failed in edr_create_table_as / delete_and_insert. Following #1049 (which did this for INSERTs), call sites that discard the result now use elementary.execute_no_fetch. dbt.run_query runs with auto_begin=false, the same as adapter.execute's default, so the only change is that no result is fetched. Unchanged: the BigQuery permission checks (SELECTs) and dbt.run_query calls in T-SQL / Postgres-only macros, which Spark never reaches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019akn5nGXcW5MA7BcVvxyo6
|
👋 @EladBarkay |
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes.
|
| Layer / File(s) | Summary |
|---|---|
Command and test SQL execution macros/commands/*, macros/edr/tests/test_all_columns_anomalies.sql, macros/edr/tests/test_utils/clean_elementary_test_tables.sql |
Command and test macros use elementary.execute_no_fetch for deletion, update, insert, and cleanup statements. |
Table-operation SQL execution macros/utils/table_operations/* |
Table-operation macros use elementary.execute_no_fetch for table creation, deletion, replacement, and related transaction statements. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Merge Risk: 
Minimal · previous review b26f3
-
The changed statements still execute while result fetching is skipped, and the inspected callers do not rely on fetched results. No concrete regression was established; the change appears ready to merge with normal adapter checks.
🚥 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 describes the main change: executing DDL/DML without fetching discarded results. Linked Issues check ✅ Passed No active directly linked issue targets remain. The only supplied direct issue, #1049, is closed and provides historical context only. No linked-issue coding requirements apply.Out of Scope Changes check ✅ Passed The reported changes replace result-fetching calls with elementary.execute_no_fetchfor DDL/DML whose results are discarded. The changed operations support the PR’s stated Spark 3.5/PyHive fix. The …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…
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: defaults
- Review profile: CHILL
- Plan: Essentials
- Run ID:
7efdd889-aa6d-4692-95a9-f797ba933daf
📒 Files selected for processing (11)
-
macros/commands/delete_duplicate_rows.sql
macros/commands/fix_nanosecond_timing_values.sql
macros/edr/tests/test_all_columns_anomalies.sql
macros/edr/tests/test_utils/clean_elementary_test_tables.sql
macros/utils/table_operations/create_or_replace.sql
macros/utils/table_operations/create_table_as.sql
macros/utils/table_operations/create_temp_table.sql
macros/utils/table_operations/delete_and_insert.sql
macros/utils/table_operations/delete_if_incremental.sql
macros/utils/table_operations/remove_rows.sql
macros/utils/table_operations/replace_table_data.sql
Included review availability: This review used your included allowance. 4 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: defaults
- Review profile: CHILL
- Plan: Essentials
- Run ID:
7efdd889-aa6d-4692-95a9-f797ba933daf
📒 Files selected for processing (11)
-
macros/commands/delete_duplicate_rows.sqlmacros/commands/fix_nanosecond_timing_values.sqlmacros/edr/tests/test_all_columns_anomalies.sqlmacros/edr/tests/test_utils/clean_elementary_test_tables.sqlmacros/utils/table_operations/create_or_replace.sqlmacros/utils/table_operations/create_table_as.sqlmacros/utils/table_operations/create_temp_table.sqlmacros/utils/table_operations/delete_and_insert.sqlmacros/utils/table_operations/delete_if_incremental.sqlmacros/utils/table_operations/remove_rows.sqlmacros/utils/table_operations/replace_table_data.sql
Included review availability: This review used your included allowance. 4 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.
-
…-breaks-on-spark-35-thrift
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Fixes CORE-1558.
Summary
On Spark 3.5 with dbt-spark's
thriftmethod (PyHive), for example on EMR or self-hosted Spark, every Elementary artifact model fails:For a
CREATE TABLE ASorINSERT, Spark 3.5's thrift server returns a row set whosecolumnsisNone. PyHive 0.7.0, which is unmaintained, iterates that field inCursor._fetch_moreand raises. Spark 3.3 and 4.2 return an empty list instead. This reproduces with PyHive alone, outside dbt:fetchall()after CTAS / INSERT[]TypeError: 'NoneType' object is not iterable[]Plain dbt isn't affected, because it runs DDL with
fetch=False.elementary.run_querywrapsdbt.run_query, which always fetches, and the DDL/DML inedr_create_table_as,delete_and_insertand the other table operations goes through it.Fix: #1049 added
elementary.execute_no_fetchfor INSERTs whose result is discarded. This PR applies the same rule to the remaining discard-result DDL/DML (22 call sites in 11 files):edr_create_table_as,delete_and_insert,delete_if_incremental,remove_rows,replace_table_data,create_or_replace,create_temp_table, test-table cleanup, theall_columns_anomaliesinsert, and thedelete_duplicate_rows/fix_nanosecond_timing_valuescommands.dbt.run_queryruns its statement withauto_begin=false, which is alsoadapter.execute's default, so transaction behavior is unchanged on every adapter. The only difference is that the result isn't fetched.Unchanged:
SELECTs, not DDL/DML.dbt.run_querycalls in T-SQL / Postgres-only macros (select ... into, the SQL Server column snapshot,create_indexes). Spark never reaches them.Local results
Run with the elementary CLI's e2e project (elementary-data/elementary's
tests/e2e_dbt_project), dbt-core 1.12.5, dbt-spark 1.11.0 with PyHive 0.7.0, against the officialapache/spark:3.5.9image with Delta 3.3.3:dbt rundbt test'NoneType' object is not iterableerror_modelfails (intentional)The 60 failures are the e2e project's expected ones, the same tests that fail on Postgres and on Spark 4.2.
edr monitor reportpasses on this branch.This repo's own Spark CI job still runs Spark 3.3.2, where the bug doesn't reproduce, so the integration tests check the other adapters but not the Spark 3.5 case.
🤖 Generated with Claude Code
https://claude.ai/code/session_019akn5nGXcW5MA7BcVvxyo6
Summary by CodeRabbit