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

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 !

i found a solution : modify the profile.xml file

  • remove UseNativeQuery=1 in connection_string_suffix

  • add execution_strategy: hive

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