Git Product home page Git Product logo

Comments (4)

jtcohen6 avatar jtcohen6 commented on August 20, 2024

@ivan-fishbrain Thanks for the issue. As it is, BigQuery doesn't support string-type partition columns, so I do think it makes sense to raise some kind of error here. The question is whether BigQuery should be the one to raise that error (as it's doing here), or if the dbt-bigquery adapter should be doing it.

The BigQuery error would be clearer if this were your first time running the model, to the effect of:

PARTITION BY expression must be DATE(<timestamp_column>), DATE(<datetime_column>), DATETIME_TRUNC(<datetime_column>, DAY/HOUR/MONTH/YEAR), a DATE column, TIMESTAMP_TRUNC(<timestamp_column>, DAY/HOUR/MONTH/YEAR), DATE_TRUNC(<date_column>, MONTH/YEAR), or RANGE_BUCKET(<int64_column>, GENERATE_ARRAY(<int64_value>, <int64_value>[, <int64_value>]))

Alternatively, dbt-bigquery could be more aggressive about validating partition column types in the PartitionConfig, and raise an error if it differs from the supported values. I think that's a reasonable approach, since we already hard-code a lot of type-logic in the render method; it just means that we'll need a PR to the dbt-bigquery adapter if ever / whenever BigQuery adds support for partitioning by a new datatype.

I'm going to transfer the issue over to the dbt-bigquery repo, since that's where the change will need to happen. Here's some pseudo-code to get you started:

class PartitionConfig(dbtClassMixin):
    ...
    
    def validate(cls, data):
         super().validate(data)
         dtype = data.get('data_type')
         supported = ("date", "timestamp", "datetime", "int")
         if dtype not in supported:
             raise ValidationError(f"Got partition data type {dtype}, expected one of {supported}")

from dbt-bigquery.

ivan-fishbrain avatar ivan-fishbrain commented on August 20, 2024

@jtcohen6 Thank you for explanation! I wasn't aware about impossibility of creation string-partitioned tables.
Then, I think dbt should at least create warn about this impossibility explicitly.

from dbt-bigquery.

github-actions avatar github-actions commented on August 20, 2024

This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please remove the stale label or comment on the issue, or it will be closed in 7 days.

from dbt-bigquery.

hugolu-1 avatar hugolu-1 commented on August 20, 2024

I think you can partition on anything now. And also under no circumstances should dbt-core be calling a function that's not even supported in bigquery, surely!

from dbt-bigquery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.