diff --git a/knowledge_base/job_with_condition_task/.gitignore b/knowledge_base/job_with_condition_task/.gitignore new file mode 100644 index 0000000..15bcc6d --- /dev/null +++ b/knowledge_base/job_with_condition_task/.gitignore @@ -0,0 +1 @@ +.databricks diff --git a/knowledge_base/job_with_condition_task/README.md b/knowledge_base/job_with_condition_task/README.md new file mode 100644 index 0000000..a10b244 --- /dev/null +++ b/knowledge_base/job_with_condition_task/README.md @@ -0,0 +1,31 @@ +# job_with_condition_task + +Example to show how a "condition task" can be used. + +## Usage + +Configure the workspace to use: +```sh +export DATABRICKS_CONFIG_PROFILE="" +``` + +Modify the SQL warehouse name in the configuration to a running SQL warehouse in your workspace. +You can list the SQL warehouses in your workspace using the following command: +```sh +databricks warehouses list +``` + +Deploy the bundle: +```sh +databricks bundle deploy +``` + +Run and observe the SQL query task is **not** executed: +```sh +databricks bundle run example_job +``` + +Run and observe the SQL query task is executed: +```sh +databricks bundle run example_job --params "run_sql_task=true" +``` diff --git a/knowledge_base/job_with_condition_task/databricks.yml b/knowledge_base/job_with_condition_task/databricks.yml new file mode 100644 index 0000000..7072060 --- /dev/null +++ b/knowledge_base/job_with_condition_task/databricks.yml @@ -0,0 +1,38 @@ +bundle: + name: job_with_condition_task + +variables: + warehouse_id: + lookup: + warehouse: "Shared Warehouse" + +resources: + jobs: + example_job: + name: "Example job to demonstrate the use of a condition task" + + tasks: + - task_key: condition + condition_task: + left: "{{ job.parameters.[run_sql_task] }}" + right: "true" + op: EQUAL_TO + + - task_key: run_query + depends_on: + - task_key: condition + outcome: "true" + + sql_task: + warehouse_id: ${var.warehouse_id} + file: + path: ./query.sql + + parameters: + - name: "run_sql_task" + default: "false" + +targets: + dev: + default: true + mode: development diff --git a/knowledge_base/job_with_condition_task/query.sql b/knowledge_base/job_with_condition_task/query.sql new file mode 100644 index 0000000..dd0ff5d --- /dev/null +++ b/knowledge_base/job_with_condition_task/query.sql @@ -0,0 +1,2 @@ +-- Dummy query to test the job with condition task +select * from range(10)