Source freshness - selecting target database

dbt source freshness for a specific database

Hey, trying to check the freshness of the source but not sure how to select the target database.
I’m running this first

dbt source freshness --select source:DATABASENAME

as I have other sources in yml file and then

dbt run --target first

but during the freshness check dbt randomly selects the target database.
Does anyone know how to solve it?
Can I use --target together with dbt source freshness command?

This is my code

sources:
  - name: DATABASENAME
    schema: STAGE
    database: |
      {%- if  target.name == "first" -%} STAGING_FIRST
      {%- elif target.name == "second"  -%} STAGING_SECOND
      {%- endif -%}

    freshness: # default freshness
      warn_after: {count: 12, period: hour}
      error_after: {count: 24, period: hour}
    loaded_at_field: insert_date

    tables:
      - name: orders
        freshness: 
          warn_after: {count: 6, period: hour}
          error_after: {count: 12, period: hour}

I am not 100% sure, but I think you can use --target in dbt source freshness, have you tried it?

Yeah, it worked actually :slight_smile: Thanks!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.