0
0
dbtdata~20 mins

Configuring sources in YAML in dbt - Practice Exercises

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Source YAML Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the effect of this source configuration in YAML?
Given this YAML snippet configuring a source in dbt, what will be the resulting source name and table name in dbt's catalog?
dbt
version: 2
sources:
  - name: sales_data
    tables:
      - name: transactions
        description: "Table of all sales transactions"
        identifier: sales_txn
ASource name: sales_data, Table name: transactions
BSource name: sales_data, Table name: sales_txn
CSource name: sales_txn, Table name: transactions
DSource name: transactions, Table name: sales_data
Attempts:
2 left
💡 Hint
Look at the 'identifier' field in the table configuration.
data_output
intermediate
1:30remaining
How many sources and tables are defined in this YAML?
Count the total number of sources and tables defined in this YAML configuration.
dbt
version: 2
sources:
  - name: marketing
    tables:
      - name: campaigns
      - name: leads
  - name: finance
    tables:
      - name: invoices
      - name: payments
      - name: refunds
A3 sources, 4 tables
B3 sources, 5 tables
C2 sources, 5 tables
D2 sources, 4 tables
Attempts:
2 left
💡 Hint
Count the top-level source entries and sum their tables.
🔧 Debug
advanced
2:00remaining
Identify the error in this source YAML configuration
What error will dbt raise when parsing this YAML source configuration?
dbt
version: 2
sources:
  - name: customer_data
    tables:
      - name: customers
        identifier: cust
      - identifier: orders
ATypeError: 'tables' must be a dictionary, not a list
BKeyError: 'identifier' missing for first table
CNo error, configuration is valid
DSyntaxError: Missing 'name' for the second table
Attempts:
2 left
💡 Hint
Check if every table entry has a 'name' key.
🧠 Conceptual
advanced
1:30remaining
What is the purpose of the 'loaded_at_field' in a source configuration?
In dbt source YAML configuration, what does the 'loaded_at_field' property specify?
AIt defines the timestamp field indicating when the source data was last loaded.
BIt sets the default schema for the source tables.
CIt specifies the primary key field of the source table.
DIt marks the field used for incremental model partitioning.
Attempts:
2 left
💡 Hint
Think about tracking freshness of source data.
🚀 Application
expert
2:30remaining
Which YAML snippet correctly configures a source with a schema override and a freshness policy?
Select the YAML snippet that correctly sets a source named 'web_logs' with a schema 'analytics', a table 'events', and a freshness policy of 24 hours.
A
version: 2
sources:
  - name: web_logs
    schema: analytics
    tables:
      - name: events
        freshness:
          warn_after: {count: 24, period: hour}
B
version: 2
sources:
  - name: web_logs
    schema: analytics
    freshness:
      warn_after: {count: 24, period: hour}
    tables:
      - name: events
C
version: 2
sources:
  - name: web_logs
    tables:
      - name: events
        schema: analytics
        freshness:
          warn_after: {count: 24, period: hour}
D
version: 2
sources:
  - name: web_logs
    schema: analytics
    tables:
      - name: events
    freshness:
      warn_after: {count: 24, period: hour}
Attempts:
2 left
💡 Hint
Freshness is set per table, schema is set per source.