Datavault-UK / automate-dv

A free to use dbt package for creating and loading Data Vault 2.0 compliant Data Warehouses (powered by dbt, an open source data engineering tool, registered trademark of dbt Labs)
https://www.automate-dv.com
Apache License 2.0
511 stars 131 forks source link

[BUG] 'dict object' has no attribute 'get_query_results_as_dict' #108

Closed RoyalTS closed 2 years ago

RoyalTS commented 2 years ago

Describe the bug Finding it hard to put a reproducible example together for this but perhaps (a) I'm just doing something wrong or (b) you can already tell what's from from the below.

I have a model that looks like this:

{{ config(materialized='vault_insert_by_period', timestamp_field='DATE_KEY_UTC', period='day',
start_date=var('start_date'), end_date=var('end_date')) }}

SELECT
    rl.city_name
    , rl.zone_id
    , rl.date_key_utc

    , COUNT(DISTINCT rl.driver_id) AS cnt_riders_present
    , COUNT(*) * 12 / 60 AS mins_present

FROM production.events.rider_locations rl
WHERE __PERIOD_FILTER__
GROUP BY rl.city_name, r.zone_id, rl.date_key_utc

On dbt run against a Snowflake DB I get

14:27:24  Completed with 1 error and 0 warnings:
14:27:24
14:27:24  Compilation Error in macro default__get_period_boundaries (macros/materialisations/period_mat_helpers/get_period_boundaries.sql)
14:27:24    'dict object' has no attribute 'get_query_results_as_dict'
14:27:24
14:27:24    > in macro get_period_boundaries (macros/materialisations/period_mat_helpers/get_period_boundaries.sql)
14:27:24    > called by macro materialization_vault_insert_by_period_default (macros/materialisations/vault_insert_by_period_materialization.sql)
14:27:24    > called by macro default__get_period_boundaries (macros/materialisations/period_mat_helpers/get_period_boundaries.sql)

(side note: what tripped me up the first time around is that the timestamp_field argument is case sensitive because it gets quoted in the resulting SQL)

Versions

dbt: 1.0.3 dbtvault: 0.8.1

DVAlexHiggs commented 2 years ago

Hi, Thanks for this report, are you on Snowflake?

RoyalTS commented 2 years ago

Yes, sorry, just added 😃

On Thu, Mar 10, 2022, 2:48 PM Alex Higgs @.***> wrote:

Hi, Thanks for this report, are you on Snowflake?

— Reply to this email directly, view it on GitHub https://github.com/Datavault-UK/dbtvault/issues/108#issuecomment-1064142568, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFLQ5C2AG3W6AZRW43CAC3U7IDU7ANCNFSM5QM3H32A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

DVAlexHiggs commented 2 years ago

Investigating now. Looks like our end. Will keep you updated!

RoyalTS commented 2 years ago

That fix seems to be doing the trick (just tested locally). You going to cut another release from this soon?

DVAlexHiggs commented 2 years ago

That fix seems to be doing the trick (just tested locally). You going to cut another release from this soon?

Yes, just running it through our test suite and we'll bundle it into the next release (0.8.2) which will be out in the next few days.

Thanks for this report!

DVAlexHiggs commented 2 years ago

@RoyalTS Just a minor point as well, your config has end_date which is incorrect, it must be stop_date (docs). If no end_date is provided, this will cause dbtvault to iterate until the current date, so this could be problematic if your date is very far in the past or if you do not want to load until the current date!

DVAlexHiggs commented 2 years ago

Fixed in 0.8.2, thanks for the report :)