# A job running SQL queries on a SQL warehouse
resources:
  jobs:
    my_default_sql_sql_job:
      name: my_default_sql_sql_job

      trigger:
        # Run this job every day, exactly one day from the last run; see https://docs.databricks.com/api/workspace/jobs/create#trigger
        periodic:
          interval: 1
          unit: DAYS

      email_notifications:
        on_failure:
          - $USERNAME

      parameters:
        - name: catalog
          default: ${var.catalog}
        - name: schema
          default: ${var.schema}
        - name: bundle_target
          default: ${bundle.target}

      tasks:
        - task_key: orders_raw
          sql_task:
            warehouse_id: ${var.warehouse_id}
            file:
              path: ../src/orders_raw.sql

        - task_key: orders_daily
          depends_on:
            - task_key: orders_raw
          sql_task:
            warehouse_id: ${var.warehouse_id}
            file:
              path: ../src/orders_daily.sql
