resources:
  jobs:
    my_dbt_sql_job:
      name: my_dbt_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


      tasks:
        - task_key: dbt

          dbt_task:
            project_directory: ../
            # The default schema, catalog, etc. are defined in ../dbt_profiles/profiles.yml
            profiles_directory: dbt_profiles/
            commands:
            # The dbt commands to run (see also dbt_profiles/profiles.yml; dev_schema is used in the dev profile)
            - 'dbt deps --target=${bundle.target}'
            - 'dbt seed --target=${bundle.target} --vars "{ dev_schema: ${workspace.current_user.short_name} }"'
            - 'dbt run --target=${bundle.target} --vars "{ dev_schema: ${workspace.current_user.short_name} }"'

          libraries:
          - pypi:
              package: dbt-databricks>=1.8.0,<2.0.0

          new_cluster:
            spark_version: 15.4.x-scala2.12
            node_type_id: i3.xlarge
            data_security_mode: SINGLE_USER
            num_workers: 0
            spark_conf:
                spark.master: "local[*, 4]"
                spark.databricks.cluster.profile: singleNode
            custom_tags:
              ResourceClass: SingleNode
