dbt-athena icon indicating copy to clipboard operation
dbt-athena copied to clipboard

prehook sql throw exception

Open lichenglin opened this issue 2 years ago • 5 comments

I wanted to excute a pre_hook query like this {{ config(materialized='view',pre_hook="drop table if exists my_first_dbt_model") }} But I found that in athena , the sql become -- /* {"app": "dbt", "dbt_version": "1.2.1", "profile_name": "local", "target_name": "dev", "node_id": "model.dbtest.my_first_dbt_model"} */ drop table if exists my_first_dbt_model since all the sql stay in one line , the sql had been miss as a comment , It failed

lichenglin avatar Sep 14 '22 13:09 lichenglin

@daniel-cortez-stevenson Hi, can this be related to https://github.com/Tomme/dbt-athena/pull/64? If so, do you know how to fix it?

Thanks!

hagai-arad avatar Oct 12 '22 12:10 hagai-arad

Yea must be - we can fix that

daniel-cortez-stevenson avatar Nov 23 '22 20:11 daniel-cortez-stevenson

Removing -- from the comment doesn't fix all the cases, e.g. alter statement:

/* {"app": "dbt", "dbt_version": "1.3.0", "profile_name": "athena", "target_name": "dev", "node_id": "model.lakehouse.example_iceberg_increment"} */ ALTER TABLE silver.example_iceberg_increment SET TBLPROPERTIES ('vacuum_max_snapshot_age_seconds'='86400')

nicor88 avatar Nov 24 '22 13:11 nicor88

Appreciate the comment @nicor88 - after seeing this I thought that statements starting on the same line as the multi-line comment ends would be executed.

I wouldn't remove the -- , I'd add a newline after the annotation.

Do we agree that's a sufficient/wanted fix?

daniel-cortez-stevenson avatar Nov 26 '22 00:11 daniel-cortez-stevenson

@daniel-cortez-stevenson feel free to open a PR here: https://github.com/dbt-athena/dbt-athena

The specific issue that I was having was cover by this pr: https://github.com/dbt-athena/dbt-athena/pull/56 as somehow I thought as well to remove -- and add a new line \n was still leading to issue.

Anyhow, the development of Tomme/dbt-athena seems a bit stuck, the community did quite some progress on the new fork, have a look.

nicor88 avatar Nov 26 '22 06:11 nicor88