Giter Club home page Giter Club logo

Comments (3)

findinpath avatar findinpath commented on May 29, 2024 2

From dbt slack

https://getdbt.slack.com/archives/C2JRRQDTL/p1637588715264700?thread_ts=1637582164.264100&cid=C2JRRQDTL

you may make use of dbt macros for adding dynamic functionality to the config element of your dbt model:

config(partitions = [parse_partition()], ...)

or simply do this:
https://docs.getdbt.com/docs/building-a-dbt-project/dont-nest-your-curlies

{{
    config(
        materialized = 'xxxxx',
        properties={
          "transactional":  var('DBT_TRANSACTION')
        }
        ...
    )
}}

from dbt-trino.

findinpath avatar findinpath commented on May 29, 2024

@bachng2017 thank you for the feedback.
It is really nice to see that the new features come to use in the community.

Regarding the 1st point, please do describe in detail your use case with concrete code snippets.
This would make it easier for us to understand what you are trying to achieve.

Same thing for the 2st point.
It seems to me that the code snippet is taken out of a dbt model. What I don't quite understand is the limitation that you are speaking about.
I assume that you want properties to be evaluated dynamically. I'm not sure whether this is possible in dbt , but i'll ask on dbt slack and get back with feedback.

from dbt-trino.

bachng2017 avatar bachng2017 commented on May 29, 2024

Let me clarify

  1. in the case we need not only transaction=true for all 10 models, but 3 models need to have partition info. What we would like to do is: set the transaction=true for all model in dbt_project.yml (a) and add parition to 1 models (b), which in total is 2 configurations.
project_path:
    + properties:
         transactional: true
     model1:  
          + properties:
                partitioned_by = ARRAY['dt']

But with the current implementation, we need to add configuration for all 10 models separately. In this case we could configure the global property as above and local property in model 1 like this, which overwrite the global

{{
    config(     
        properties={
          "transactional":  "true",
         "partitioned_by" = "ARRAY['dt']"
        }
        ...
    )
}}

But let image we have more models, more common properties, the configuration will be more redundant.

Notes that in this case partition and transaction are only samples. The point is how efficient to write the configuration for a large number of models with common properties and some few special cases.

  1. Yes, we could use var ad you've describe to achieve dynamic configuretion in dbt. But defining a transactional = true/false is not enough. The code will not run in the environment where transaction is not understood at all like this one. We need a way to "remove" the property dynamically.
> create table test (id int) with (transactional='false');
Query 20211206_115505_02613_jzqcx failed: Catalog 'hive' does not support table property 'transactional'

for .2 we are now have a small patch for adapters.sql as following. It works in our case but not sure for other cases

...
227 {% macro properties(properties) %}
228   {% set _properties = {} %}
229   {% for key, value in properties.items() %}
230     {% if value is defined and value != '' %}
231         {% do _properties.update({key:value}) %}
232     {% endif %}
233   {% endfor %}
234
235   {%- if _properties | length  -%}
236       WITH (
237           {%- for key, value in _properties.items() -%}
238             {{ key }} = {{ value }}
239             {%- if not loop.last -%}{{ ',\n  ' }}{%- endif -%}
240           {%- endfor -%}
241       )
242   {%- endif -%}
243 {%- endmacro -%}

from dbt-trino.

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.