fivetran / dbt_apple_store

Fivetran's Apple App Store source dbt package
https://fivetran.github.io/dbt_apple_store/
Apache License 2.0
0 stars 2 forks source link

[Bug] #8

Closed lch88 closed 1 year ago

lch88 commented 1 year ago

Is there an existing issue for this?

Describe the issue

Building apple_store__subscription_report model fails with following error on BigQuery.

21:44:25  Completed with 1 error and 0 warnings:
21:44:25  
21:44:25  Database Error in model apple_store__subscription_report (models/apple_store__subscription_report.sql)
21:44:25    No matching signature for operator = for argument types: DATE, STRING. Supported signature: ANY = ANY at [243:12]
21:44:25    compiled Code at target/run/apple_store/models/apple_store__subscription_report.sql
21:44:25  
21:44:25  Done. PASS=27 WARN=0 ERROR=1 SKIP=1 TOTAL=29

The code referred here seems to be: https://github.com/fivetran/dbt_apple_store/blob/0e7ea500f5303c95afb0da395502ee5b81f6c9f5/models/apple_store__subscription_report.sql#L88

Relevant error log or model output

Error log itself is provided above.

Expected behavior

It should run without any issue.

dbt Project configurations

I have set the using_subscriptions flag to true.

vars:
  # set source database and schema name (https://github.com/fivetran/dbt_app_reporting#step-3-configure-database-and-schema-variables)
  apple_store_database: project-XXX
  apple_store_schema: itunes_connect
  google_play_database: project-XXX
  google_play_schema: google_play

  # enable subscriptions and earnings models (https://github.com/fivetran/dbt_app_reporting#step-4-disable-and-enable-source-tables)
  apple_store__using_subscriptions: true # by default this is assumed to be false
  google_play__using_subscriptions: true # by default this is assumed to be false
  google_play__using_earnings: true # by default this is assumed to be false

Package versions

packages:

What database are you using dbt with?

bigquery

dbt Version

Core:

Plugins:

Additional Context

As a temporary measure, I changed the line to

reporting_grain.date_day = cast(subscription_events.date_day as date)

and it worked.

Maybe it would be better if it is fixed in other location like upstream model.

Are you willing to open a PR to help address this issue?

fivetran-joemarkiewicz commented 1 year ago

Thanks so much for opening this issue @lch88 and sorry to see you are running into this issue.

I see you were able to resolve the issue by casting the date_day as date in the join condition. While that will fix the issue here, I actually think it may be better to cast the field appropriately in the upstream staging model.

We should be able to cast the field here in the source package: https://github.com/fivetran/dbt_apple_store_source/blob/85717fa3aae076235a34fb337e9826f03f8293e2/models/stg_apple_store__sales_subscription_events.sql#L25

This should then resolve the join error you are seeing. I notice you are open to creating a PR. Would you be interested in applying this fix in the source package? We would be able to review and work to fold it into the next patch release to address the bug. Otherwise, my team can pick this up in our next sprint.

Let me know!

lch88 commented 1 year ago

@fivetran-joemarkiewicz I'm happy to work on the PR. I'll submit one maybe in about a day.

fivetran-joemarkiewicz commented 1 year ago

Brilliant @lch88! 🎉 Let me know if you need any support with the PR.

lch88 commented 1 year ago

@fivetran-joemarkiewicz Submitted a PR on dbt_apple_store_source repo!

fivetran-joemarkiewicz commented 1 year ago

Thanks so much @lch88! I will review this week and let you know if I have any requests before rolling out to the next release!

fivetran-joemarkiewicz commented 1 year ago

Closing this issue as PR #7 addresses the issue originally identified within this bug report.