On running "edr report", getting [TEMP_VIEW_NAME_TOO_MANY_NAME_PARTS] error
Describe the bug When I run "edr report", I get the following error:
{"exc": "Database Error\n Database Error\n \n [TEMP_VIEW_NAME_TOO_MANY_NAME_PARTS] CREATE TEMPORARY VIEW or the corresponding Dataset APIs only accept single-part view names, but got: xxxx.xxxx.ordered_test_results__tmp_20250411133400890570. SQLSTATE: 428EK\n == SQL (line 5, position 5) ==\n create or replace temporary view xxxx.xxxx.ordered_test_results__tmp_20250411133400890570 as\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n \n ^^^^^^\n with test_results as (\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n \n ^^^^^^^^^^^^\n with elementary_test_results as (\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n select * from xxxx.xxxx.`elementary_test_results
To Reproduce Steps to reproduce the behavior:
- Add - package: elementary-data/elementary in the packages.yml file
- Run "dbt deps"
- Run "dbt run --select elementary"
- Run "dbt test"
- Run "edr report"
Expected behavior The command should read from the Elementary tables, and generate the report as an HTML file.
Environment (please complete the following information):
- Elementary CLI (edr) version: 0.18.1
- Elementary dbt package version: 0.18.2
- dbt version you're using: 1.9.3
- Data warehouse and version of adapater: Databricks/1.9.7
Additional context Tried downgrading to elementary 0.17.0 but still faced the same issue.
Would you be willing to contribute a fix for this issue? Yes
File to fix:
.venv/lib/python3.13/site-packages/elementary/monitor/dbt_project/macros/create_temp_table.sql
Add the following code:
{% macro databricks__create_temp_table(database_name, schema_name, table_name, sql_query) %}
{% set temp_table_exists, temp_table_relation = dbt.get_or_create_relation(database=database_name,
schema=schema_name,
identifier=table_name,
type='table') -%}
{% set temp_table_relation = elementary.make_temp_table_relation(temp_table_relation) %}
{% do elementary.run_query(dbt.create_table_as(True, temp_table_relation.identifier, sql_query)) %}
{{ return(temp_table_relation.identifier) }}
{% endmacro %}
Fix notes: databricks just needs the table part of temp_table_relation. spark might need an adapter specific code block too (use above code and replace databricks with spark)
temp_table_relation: "jaffle_shop"."dbo"."ordered_test_results__tmp_20250414164334884652"
temp_table_relation.identifier: ordered_test_results__tmp_20250414164334884652
elementary.run_query: runs create or replace temporary view ordered_test_results__tmp_20250414164334884652
Additional notes: create_temp_table exists three times at the following locations with inconsistent code across them. Only the location above seems to be used:
.venv/lib/python3.13/site-packages/elementary/monitor/dbt_project/macros/create_temp_table.sql --fix works here
.venv/lib/python3.13/site-packages/elementary/monitor/dbt_project/dbt_packages/elementary/macros/utils/table_operations/create_temp_table.sql -- inconsistent code
/dbt_packages/elementary/macros/utils/table_operations/create_temp_table.sql -- not used by edr report. could be used else where?
Python 3.12 has elementary-data version 0.18.1 installed by default. Python 3.13 installed 0.17.0 which the above fix works for. On 3.12 there is still an error which I will look into.
To force 3.12 back to 0.17 run the following:
pip install elementary-data==0.17.0
On python 3.12 using pip install --upgrade elementary-data to get back to 0.18.1 and applying the databricks fix to
dbt_packages/elementary/macros/utils/table_operations/create_temp_table.sql still fixes the issue.
There seems to be another error now to do with below which seems different.
.venv3_12/lib/python3.12/site-packages/elementary/clients/dbt/api_dbt_runner.py has a comment in it saying:
# type: ignore[arg-type] <-- the error calls out type so suspect it is something to do with this.
Given its a different error someone else will need to pick this up.
Traceback (most recent call last): File "/.venv3_12/lib/python3.12/site-packages/elementary/monitor/api/report/report.py", line 84, in get_report_data tests_api = TestsAPI(
2025-04-15 12:38:08 — ERROR — Could not generate the report - Error: Failed to run dbt command. {"info": {"name": "RunningOperationCaughtError", "code": "Q001", "msg": "Encountered an error while running operation: Database Error\n 'str' object has no attribute 'type'", "level": "error", "invocationId": "dac91512-3614-4595-9f1f-c74c10626ea5", "pid": 26933, "thread": "MainThread", "ts": "2025-04-15T11:38:08.811561Z"}, "data": {"exc": "Database Error\n 'str' object has no attribute 'type'"}} Please reach out to our community for help with this issue.
.....
File "/.venv3_12/lib/python3.12/site-packages/elementary/clients/dbt/command_line_dbt_runner.py", line 114, in _run_command result = self._inner_run_command( ^^^^^^^^^^^^^^^^^^^^^^^^ File "/.venv3_12/lib/python3.12/site-packages/elementary/clients/dbt/api_dbt_runner.py", line 54, in _inner_run_command raise DbtCommandError(
elementary.exceptions.exceptions.DbtCommandError: Failed to run dbt command. {"info": {"name": "RunningOperationCaughtError", "code": "Q001", "msg": "Encountered an error while running operation: Database Error\n 'str' object has no attribute 'type'", "level": "error", "invocationId": "dac91512-3614-4595-9f1f-c74c10626ea5", "pid": 26933, "thread": "MainThread", "ts": "2025-04-15T11:38:08.811561Z"}, "data": {"exc": "Database Error\n 'str' object has no attribute 'type'"}} ERROR:elementary.monitor.data_monitoring.report.data_monitoring_report:Could not generate the report - Error: Failed to run dbt command. {"info": {"name": "RunningOperationCaughtError", "code": "Q001", "msg": "Encountered an error while running operation: Database Error\n 'str' object has no attribute 'type'", "level": "error", "invocationId": "dac91512-3614-4595-9f1f-c74c10626ea5", "pid": 26933, "thread": "MainThread", "ts": "2025-04-15T11:38:08.811561Z"}, "data": {"exc": "Database Error\n 'str' object has no attribute 'type'"}} Please reach out to our community for help with this issue.
Is there a planned fix for this?
This issue is stale because it has been open for too long with no activity. If you would like the issue to remain open, please remove the stale label or leave a comment.