question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide model definition when using ref override

See original GitHub issue

Hi,

This is a suggestion for the model definition provider.

Sometimes an override is used for ref in dbt projects and it would be really nice to have the model definition shortcut working in such cases.

Example override:

{% macro ref_no_db(model_name) %}
  {% do return(builtins.ref(model_name).include(database=false)) %}
{% endmacro %}

Suggested solution: override macro must start with “ref_” to simplify parsing.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mdesmetcommented, Feb 2, 2022

If your overriden ref is not smart enough, then make it smarter: You can get the current scheme and current database and compare it towards the input, if it’s not the same you keep the database.

0reactions
rodikcommented, Feb 17, 2022

This is the override we ended up with:

{% macro ref(model_name) %}

  {% if config.get('materialized') == "view" %}
    {% do return(builtins.ref(model_name).include(database=false)) %}
  {% else %}
    {% do return(builtins.ref(model_name).include(database=true)) %}
  {% endif %}

{% endmacro %}

Views are really the only type of model where 2-part names are needed. Everything else defaults to original ref and 3-part names.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using $ref
Local Reference – $ref: '#/definitions/myElement' # means go to the root of the current document and then find elements definitions and myElement one...
Read more >
Swagger schema properties ignored when using $ref
A possible workaround is to wrap $ref into allOf - this can be used to "add" attributes to a $ref but not override...
Read more >
Allow sibling elements with $ref that overrides the ...
Currently I can either specify a $ref or the complete property description. However there are use cases where refenced definition needs to be ......
Read more >
Refs and the DOM
Refs provide a way to access DOM nodes or React elements created in the render method. ... Avoid using refs for anything that...
Read more >
ref keyword - C# Reference
To use a ref parameter, both the method definition and the calling ... such as hiding or overriding, in , ref , and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found