DBT question specifically, any easy way to ignore ...
# plugins-dbt
v
DBT question specifically, any easy way to ignore metadata information from sources? I currently do select * from source() , and I don't want the metadata info coming over. I'm guessing I'm glossing over something in the docs
ie I don't want
_sdc_extracted_at
etc
t
My cheeky answer is to not do
select *
. 😛 but the real answer would be to use https://github.com/dbt-labs/dbt-utils#star-source and include the columns you don't want to select. You could also make a macro that you build once which removes the columns you don't want and then just reference that macro
v
Sorry, I totally forgot about this thread, I'll put the answer in here I went with. You're probably right on the
select *
being wrong. In my context it's probably ok, but I think I'd 100% agree in an analytics context (and I bet you'll end up being right even about my context)
cleaned_source.sql
Copy code
{% macro cleaned_source(source_name, table_name) %}
    select
    {{ dbt_utils.star(from=source(source_name, table_name), except=["_sdc_received_at", "_sdc_batched_at", "_sdc_extracted_at", "_sdc_deleted_at", "_sdc_table_version", "_sdc_sequence"]) }}
    from {{ source(source_name, table_name) }}    
{% endmacro %}
example stage model file
Copy code
with source as (

        {{ cleaned_source('source_name', 'table_name') }}

), final AS (
	select 
	*
	from source
)
select * from final
Thanks again
t
that's almost exactly what I would've done - so perfect solution there Derek! 😛
v
I think I've made it, I have a follow from you on the twitter and you just said I made a perfect DBT solution 😄