# dbt tests failing with "Returned 0 rows, but expected 1 row" - run\_query() returns None with Spark + ODBC + Hive

**URL:** <https://discourse.getdbt.com/t/dbt-tests-failing-with-returned-0-rows-but-expected-1-row-run-query-returns-none-with-spark-odbc-hive/20109>\
**Category:** Help\
**Tags:** testing, dbt-core\
**Created:** [August 13, 2025, 9:33am UTC](https://discourse.getdbt.com/t/dbt-tests-failing-with-returned-0-rows-but-expected-1-row-run-query-returns-none-with-spark-odbc-hive/20109 "2025-08-13T09:33:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dpit](https://avatars.discourse-cdn.com/v4/letter/d/ecccb3/32.png) [@dpit](https://discourse.getdbt.com/u/dpit)\
**Post date:** [August 13, 2025, 9:33am UTC](https://discourse.getdbt.com/t/dbt-tests-failing-with-returned-0-rows-but-expected-1-row-run-query-returns-none-with-spark-odbc-hive/20109/1 "2025-08-13T09:33:14Z")

</div>

**Hello** i’m beginner on dbt and I’m experiencing issues with dbt tests when using **dbt-spark** with **ODBC connection** to **Cloudera Hive**. All standard tests (unique, not\_null, etc.) fail with the same error pattern.

**Environment:**

- dbt version: 1.10.8

- dbt-spark version: 1.9.3

- Connection: ODBC to Cloudera Hive

- Connection string includes: `UseNativeQuery=1` (required for our SQL compatibility)

**Error Details:**

1. **Standard dbt tests fail** with: `Internal Error: dbt internally failed to execute test.xxx: Returned 0 rows, but expected 1 row`

2. **Custom macros using `run_query()` also fail** in post-hooks:

**Question:** Has anyone encountered similar issues with **dbt-spark + ODBC + Hive** where `run_query()` works from CLI but returns `None` during model execution? Is this a known limitation of the dbt-spark adapter with ODBC connections?

Any workarounds or alternative approaches for data validation in this setup would be greatly appreciated.

Thank a lot !

---

<div class="post-metadata">

**Author:** ![dpit](https://avatars.discourse-cdn.com/v4/letter/d/ecccb3/32.png) [@dpit](https://discourse.getdbt.com/u/dpit)\
**Post date:** [August 13, 2025, 12:32pm UTC](https://discourse.getdbt.com/t/dbt-tests-failing-with-returned-0-rows-but-expected-1-row-run-query-returns-none-with-spark-odbc-hive/20109/2 "2025-08-13T12:32:37Z")

</div>

i found a solution : modify the `profile.xml file `

- remove UseNativeQuery=1 in connection\_string\_suffix

- add` execution_strategy: hive`

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/1X/a7a7ca1fe379aaf90952b0e13118a817babcd14f.png) [@system](https://discourse.getdbt.com/u/system)\
**Post date:** [August 20, 2025, 12:32pm UTC](https://discourse.getdbt.com/t/dbt-tests-failing-with-returned-0-rows-but-expected-1-row-run-query-returns-none-with-spark-odbc-hive/20109/3 "2025-08-20T12:32:53Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
