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

[Bug] BigQuery - using _PARTITIONTIME column leads to Unrecognized name error #119

Open
yoheimiyamoto opened this issue Feb 14, 2023 · 0 comments
Labels
needs investigation This issue must be investigated

Comments

@yoheimiyamoto
Copy link

yoheimiyamoto commented Feb 14, 2023

dbt test with include_missing_columns fails with Unrecognized name: _PARTITIONTIME error.

Error message

dbt test

tests/unit/pv.sql
Unrecognized name: _partitiondate at [21:9]

Sample Code

Staging

models/staging/stg_datafeed.sql

with

source as (
    select
        *
        ,  _partitiondate as  partitiondate
    from
        {{ source('datafeed', 'datafeed_ap') }}
)

select
    session_id
    , date_time
    , pagename
from
    source

Model

models/pv.sql

with

source as (
    select
        *
    from
        {{ ref('stg_datafeed') }}
)

select distinct
    session_id
    , count(*) as pv
from
    source
group by
    session_id

Test

tests/unit/pv.sql

{{ config(tags=['unit-test']) }}

{% set options = {"include_missing_columns": True} %}

{% call dbt_unit_testing.test('pv', 'should have 2 records') %}
  
  {% call dbt_unit_testing.mock_ref('stg_datafeed__ap', options) %}
    select '1' as session_id union all
    select '1' as session_id union all
    select '2' as session_id
  {% endcall %}
  
  {% call dbt_unit_testing.expect() %}
    select '1' as session_id, 2 as pv
    union all
    select '2' as session_id, 1 as pv
  {% endcall %}

{% endcall %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation This issue must be investigated
Projects
None yet
Development

No branches or pull requests

2 participants