Open jtcohen6 opened 2 years ago
Would we consider exposing a python type function like isinstance()
or type()
to the jinja context directly?
Chiming in here - I would find isinstance/type useful for a use case I have. I'm processing data in macro that comes from the config/meta dictionaries and being able to understand the the data type of the value in the dictionary would be useful.
Many
dbt_utils
macros need to access information about an underlying table, by runningadapter.get_columns_in_relation
or a custom query.Those macros expect to be passed a
ref
,source
, or otherRelation
object, and for it to represent an object that really exists in the database. To ensure that's the case, and raise a helpful error if it isn't, they first call "internal helper" macros,_is_relation
and_is_ephemeral
, to check that the passed argument (a) really is a Relation, (b) isn't ephemeral (= exists as a database object, assuming it's already been run).Because this is Jinja, we can't just call
isinstance
, or classmethods. We have to check meta properties.dbt_utils._is_relation
dbt_utils._is_ephemeral
There is a node method, is_ephemeral, but nothing available on the actual
Relation
object returned byref
... except theis_cte
property:Questions
Relation
object, to make it accessible in the Jinja layer?adapter.get_columns_in_relation
?