dbt-labs / dbt-labs/dbt-adapters

[Bug] dbt source freshness expected a timestamp but received a string

Open
#426 2 comments 1 reaction 0 assignees View on GitHub
pkg:dbt-athena type:bug
Dominant language
Python
Stars
233
Forks
362
Avg merge
3d 22h
Merged PRs (30d)
9

Description

### Is this a new bug in dbt-athena?

- [X] I believe this is a new bug in dbt-athena
- [X] I have searched the existing issues, and I could not find an existing issue for this bug

### Current Behavior

I'm trying to run a freshness check on some of my tables using a timestamp column. However, I'm getting an error saying the check found a str column instead of a timestamp one. I believe this is a bug, because athena shows my column as a timestamp according to the following image.

![image](https://github.com/dbt-labs/dbt-adapters/assets/2208226/fd1188e6-8c2b-40f6-a382-5e3cca7454e1)

The error I'm getting is also in the following image:

![image](https://github.com/dbt-labs/dbt-adapters/assets/2208226/8c5c373b-0fbf-499f-99b8-b9ba144e63b2)

My dbt_athena package in in version 1.7.2. The query generated by the freshness code is below as the results it produced

```
select
max(loaded_at) as max_loaded_at,
cast(now() as timestamp) as snapshotted_at
from "awsdatacatalog"."bronze_dev"."callbacks"
```

![image](https://github.com/dbt-labs/dbt-adapters/assets/2208226/f3a24eda-7fc7-402c-a6fa-5ff7d7993aac)

### Expected Behavior

The dbt source freshness command should be able to run successfully on my source tables. Otherwise, it should point some error related with the SLA configured, not throw an error related with casting types.

### Steps To Reproduce

1. Have a table on athena with a timestamp column (In my case the column was generated by a pyspark script executed on aws glue)
2. Configure the dbt freshness on the same table:
version: 2

```
sources:
- name: "bronze_dev}"
tables:
- name: my_table
freshness:
error_after:
count: 2
period: day
loaded_at_field: loaded_at
```

run the command `dbt source freshness`

### Environment

```markdown
- OS: Windows
- Python: ^3.11
- dbt: 1.7.9
- dbt-athena-community: 1.7.2
```

### Additional Context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.