Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in model core__stg_claims_condition when casting dates #460

Open
thutuva opened this issue May 8, 2024 · 0 comments
Open

Error in model core__stg_claims_condition when casting dates #460

thutuva opened this issue May 8, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@thutuva
Copy link
Member

thutuva commented May 8, 2024

Environment - REQUIRED

  • Tuva project package version (e.g. 0.6.0): [">=0.8.0","<0.9.0"]
  • dbt version (e.g v1.7): >=1.5
  • Data warehouse (e.g. Snowflake, BigQuery): Postgres

Describe the bug - REQUIRED
A clear and concise description of what the bug is.

When running TTP, an error message occurs:
Database Error in model core__stg_claims_condition (models/core/staging/core__stg_claims_condition.sql)
operator does not exist: date ~ text
LINE 503: when unpivot_cte.recorded_date similar to '[0-9]{4}-[0...

Steps to reproduce the behavior:

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

I believe this error is occurring because of double casting of data types which conflicts with the try_to_cast_date.sql macro.
All columns for the claims input layer are cast to the correct data types in the preprocessing (i.e. normalized input). All other models/marts, especially Core, run off the normalized input layer which means that data types should be correct and not need any further casting. However in the core__stg_claims_condition.sql model, the final output column are being cast again but the date column are using the try_to_cast_date.sql. The macro uses regex to determine if a column can be cast to a date but this regex must be used on a column that is a string. Since the column, recorded_date, is already a date it creates an error.

TL;DR Remove all the casting from the final SELECT in core__stg_claims_condition.sql

@thutuva thutuva added the bug Something isn't working label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant