Skip to content

edr report error on Athena due to incorrect table_type="hive" #1832

Open
@gontzalm

Description

@gontzalm

Describe the bug
After the changes introduced in v0.16.2, the edr report command fails with the following Athena error:

NOT_SUPPORTED: Incorrect timestamp precision for timestamp(6); the configured precision is MILLISECONDS; column name: detected_at.

To Reproduce
Steps to reproduce the behavior:

  1. Run edr report with an elementary profile with type: athena.

Expected behavior
The report is generated without issues.

Environment (please complete the following information):

  • Elementary CLI (edr) version: 0.16.2
  • Elementary dbt package version: 0.16.4
  • dbt version: 1.9.2
  • Data warehouse: athena (dbt-athena==1.9.1)

Additional context
The error occurs when running the elementary_cli.get_test_results macro:

2025-02-20 12:48:19 — INFO — Running dbt command --log-format json run-operation elementary.log_macro_results --args {"macro_name": "elementary_cli.get_test_results", "macro_args": {"days_back": 7, "invocations_per_test": 720, "disable_passed_test_metrics": false}} --project-dir /Users/49353/dbt/.venv/lib/python3.13/site-packages/elementary/monitor/dbt_project
2025-02-20 12:50:16 — ERROR — Could not generate the report - Error: Failed to run dbt command.
{"info": {"name": "RunningOperationCaughtError", "code": "Q001", "msg": "Encountered an error while running operation: Runtime Error\n  Runtime Error\n    NOT_SUPPORTED: Incorrect timestamp precision for timestamp(6); the configured precision is MILLISECONDS; column name: detected_at. You may need to manually clean the data at location 's3://tendam-temporary/dbt/tables/e036cef7-71f4-499d-935b-fe1c9f37748d' before retrying. Athena will not delete data in your account.", "level": "error", "invocationId": "7ad27197-17fa-4c8c-afc4-35dd624bf45a", "pid": 6096, "thread": "MainThread", "ts": "2025-02-20T11:50:15.651080Z"}, "data": {"exc": "Runtime Error\n  Runtime Error\n    NOT_SUPPORTED: Incorrect timestamp precision for timestamp(6); the configured precision is MILLISECONDS; column name: detected_at. You may need to manually clean the data at location 's3://tendam-temporary/dbt/tables/e036cef7-71f4-499d-935b-fe1c9f37748d' before retrying. Athena will not delete data in your account."}}
Please reach out to our community for help with this issue

This is because now the get_test_results macro creates the temporary table

-- /* {"app": "dbt", "dbt_version": "1.9.2", "profile_name": "elementary", "target_name": "default", "connection_name": "macro_log_macro_results"} */
create table "awsdatacatalog"."elementary"."ordered_test_resultsNone"
    with (
      table_type='hive',
      is_external=true,external_location='s3://tendam-temporary/dbt/tables/elementary/ordered_test_resultsNone/18a5eb4c-ef6e-4d13-9f40-291e129d9dba',
      format='parquet'
    )
    as
    ...

instead of querying athena directly. Setting table_type='iceberg' (in line with the get_default_table_type macro) solves the issue.

Would you be willing to contribute a fix for this issue?
Yes, if appropriate guidance is provided 😄.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions