Skip to content

Commit

Permalink
fix: handle alias different to name and default meta (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
chamini2 authored Dec 16, 2022
1 parent f18be27 commit 07a0fa3
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions macros/__f__load_meta.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,22 @@
{% endif %}

{% if feature_store.__f__is_relation(obj) %}
{# Set default meta #}
{% set meta = {} %}

{# Find the meta of the `obj` relation #}
{# Try in models #}
{% set nodes = graph.nodes.values()
| selectattr("resource_type", "equalto", "model")
| selectattr("database", "equalto", obj.table.database)
| selectattr("schema", "equalto", obj.table.schema)
| selectattr("name", "equalto", obj.table.identifier)
| selectattr("alias", "equalto", obj.table.identifier)
| list %}

{% if nodes %}
{% set meta = nodes[0].config.meta %}
{% else %}
{# Try in sources #}
{% set nodes = graph.sources.values()
| selectattr("resource_type", "equalto", "source")
| selectattr("database", "equalto", obj.table.database)
| selectattr("schema", "equalto", obj.table.schema)
| selectattr("name", "equalto", obj.table.identifier)
| list %}
{% set meta = nodes[0].meta %}
{% if nodes[0].resource_type == "model" %}
{% set meta = nodes[0].config.meta %}
{% elif nodes[0].resource_type == "source" %}
{% set meta = nodes[0].meta %}
{% endif %}
{% endif %}

{# Populate any non-set properties available in the feature_store meta #}
Expand Down

0 comments on commit 07a0fa3

Please sign in to comment.