elementary-data / elementary

The dbt-native data observability solution for data & analytics engineers. Monitor your data pipelines in minutes. Available as self-hosted or cloud service with premium features.
https://www.elementary-data.com/
Apache License 2.0
1.94k stars 165 forks source link

Bug: Creating Elementary models fails on Athena Engine V3 #1678

Closed oliviercar0n closed 3 months ago

oliviercar0n commented 3 months ago

Describe the bug

When following the instructions to set up Elementary on a project with Athena data warehouse, the following error is encountered when creating the Elementary models

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

This is a known issue with Athena and CTAS statements. See additional context below

To Reproduce Steps to reproduce the behavior:

  1. Add Elementary package 0.16.0 to a dbt project
  2. Run the following command as specific in the documentation
    dbt run --select elementary

Expected behavior All model complete successfully

Screenshots

CleanShot 2024-08-22 at 12 08 54

CleanShot 2024-08-22 at 12 13 27

Environment (please complete the following information):

Additional context

This error is documented in the Athena Engine V3 release notes

Athena engine version 3 checks to make sure that the precision of timestamps in the data is the same as the precision specified for the column data type in the table specification. Currently, this precision is always 3. If the data has a precision greater than this (for example, microseconds instead of milliseconds), queries can fail with the error noted. [...] Then, because Athena does not support timestamp 6, cast the value again to timestamp (for example, in a view).

Would you be willing to contribute a fix for this issue? Yes I would be willing to help contribute a fix

oliviercar0n commented 3 months ago

It appears it tries to create views as table

-- /* {"app": "dbt", "dbt_version": "1.8.3", "profile_name": "athena_finance", "target_name": "dev", "node_id": "model.elementary.metrics_anomaly_score"} */

    create table "awsdatacatalog"."dbt_oli"."metrics_anomaly_score"
    with (
      table_type='hive',
      is_external=true,external_location='s3://<redacted>/dbt/dev/output/dbt_oli/metrics_anomaly_score/7ee042ca-bf21-45ba-b9d7-7e03ff67bc58',
      write_compression='SNAPPY',
      format='parquet'
    )
    as
oliviercar0n commented 3 months ago

There was a global materialization config that affected Elementary models. Closing.