airflow.providers.databricks.operators.databricks¶
This module contains Databricks operators.
Attributes¶
Classes¶
Constructs a link to monitor a Databricks Job Run. |
|
Creates (or resets) a Databricks job using the API endpoint. |
|
Submits a Spark job run to Databricks using the api/2.1/jobs/runs/submit API endpoint. |
|
Runs an existing Spark job run to Databricks using the api/2.1/jobs/run-now API endpoint. |
|
Submits a Databricks SQL Statement to Databricks using the api/2.0/sql/statements/ API endpoint. |
|
Base class for operators that are run as Databricks job tasks or tasks within a Databricks workflow. |
|
Runs a notebook on Databricks using an Airflow operator. |
|
Runs a task on Databricks using an Airflow operator. |
Functions¶
|
Check if the repair reason matches the run state message. |
|
Update job settings(partial) to repair the run with all failed tasks. |
Module Contents¶
- airflow.providers.databricks.operators.databricks.is_repair_reason_match_exist(operator, run_state)[source]¶
Check if the repair reason matches the run state message.
- Parameters:
operator (Any) – Databricks operator being handled
run_state (airflow.providers.databricks.hooks.databricks.RunState) – Run state of the Databricks job
- Returns:
True if repair reason matches the run state message, False otherwise
- Return type:
- airflow.providers.databricks.operators.databricks.update_job_for_repair(operator, hook, job_id, run_state)[source]¶
Update job settings(partial) to repair the run with all failed tasks.
- Parameters:
operator (Any) – Databricks operator being handled
hook (Any) – Databricks hook
job_id (int) – Job ID of Databricks
run_state (airflow.providers.databricks.hooks.databricks.RunState) – Run state of the Databricks job
- class airflow.providers.databricks.operators.databricks.DatabricksJobRunLink[source]¶
Bases:
airflow.sdk.BaseOperatorLinkConstructs a link to monitor a Databricks Job Run.
- name = 'See Databricks Job Run'[source]¶
Name of the link. This will be the button name on the task UI.
- get_link(operator, *, ti_key)[source]¶
Link to external system.
- Parameters:
operator (airflow.providers.databricks.version_compat.BaseOperator) – The Airflow operator object this link is associated to.
ti_key (airflow.models.taskinstancekey.TaskInstanceKey) – TaskInstance ID to return link for.
- Returns:
link to external system
- Return type:
- class airflow.providers.databricks.operators.databricks.DatabricksCreateJobsOperator(*, json=None, name=None, description=None, tags=None, tasks=None, job_clusters=None, email_notifications=None, webhook_notifications=None, notification_settings=None, timeout_seconds=None, schedule=None, max_concurrent_runs=None, git_source=None, access_control_list=None, databricks_conn_id='databricks_default', polling_period_seconds=30, databricks_retry_limit=3, databricks_retry_delay=1, databricks_retry_args=None, **kwargs)[source]¶
Bases:
airflow.providers.databricks.version_compat.BaseOperatorCreates (or resets) a Databricks job using the API endpoint.
See also
https://docs.databricks.com/api/workspace/jobs/create https://docs.databricks.com/api/workspace/jobs/reset
- Parameters:
json (Any | None) –
A JSON object containing API parameters which will be passed directly to the
api/2.1/jobs/createendpoint. The other named parameters (i.e.name,tags,tasks, etc.) to this operator will be merged with this json dictionary if they are provided. If there are conflicts during the merge, the named parameters will take precedence and override the top level json keys. (templated)See also
For more information about templating see Jinja Templating.
name (str | None) – An optional name for the job.
description (str | None) – An optional description for the job.
tags (dict[str, str] | None) – A map of tags associated with the job.
tasks (list[dict] | None) – A list of task specifications to be executed by this job. Array of objects (JobTaskSettings).
job_clusters (list[dict] | None) – A list of job cluster specifications that can be shared and reused by tasks of this job. Array of objects (JobCluster).
email_notifications (dict | None) – Object (JobEmailNotifications).
webhook_notifications (dict | None) – Object (WebhookNotifications).
notification_settings (dict | None) – Optional notification settings.
timeout_seconds (int | None) – An optional timeout applied to each run of this job.
schedule (dict | None) – Object (CronSchedule).
max_concurrent_runs (int | None) – An optional maximum allowed number of concurrent runs of the job.
git_source (dict | None) – An optional specification for a remote repository containing the notebooks used by this job’s notebook tasks. Object (GitSource).
access_control_list (list[dict] | None) –
List of permissions to set on the job. Array of object (AccessControlRequestForUser) or object (AccessControlRequestForGroup) or object (AccessControlRequestForServicePrincipal).
See also
This will only be used on create. In order to reset ACL consider using the Databricks UI.
databricks_conn_id (str) – Reference to the Databricks connection. (templated)
polling_period_seconds (int) – Controls the rate which we poll for the result of this run. By default the operator will poll every 30 seconds.
databricks_retry_limit (int) – Amount of times retry if the Databricks backend is unreachable. Its value must be greater than or equal to 1.
databricks_retry_delay (int) – Number of seconds to wait between retries (it might be a floating point number).
databricks_retry_args (dict[Any, Any] | None) – An optional dictionary with arguments passed to
tenacity.Retryingclass.
- template_fields: collections.abc.Sequence[str] = ('json', 'databricks_conn_id')[source]¶
- class airflow.providers.databricks.operators.databricks.DatabricksSubmitRunOperator(*, json=None, tasks=None, spark_jar_task=None, notebook_task=None, spark_python_task=None, spark_submit_task=None, pipeline_task=None, dbt_task=None, new_cluster=None, existing_cluster_id=None, libraries=None, run_name=None, timeout_seconds=None, databricks_conn_id='databricks_default', polling_period_seconds=30, databricks_retry_limit=3, databricks_retry_delay=1, databricks_retry_args=None, do_xcom_push=True, idempotency_token=None, access_control_list=None, wait_for_termination=True, git_source=None, deferrable=conf.getboolean('operators', 'default_deferrable', fallback=False), **kwargs)[source]¶
Bases:
airflow.providers.databricks.version_compat.BaseOperatorSubmits a Spark job run to Databricks using the api/2.1/jobs/runs/submit API endpoint.
See: https://docs.databricks.com/dev-tools/api/latest/jobs.html#operation/JobsRunsSubmit
There are three ways to instantiate this operator.
See also
For more information on how to use this operator, take a look at the guide: DatabricksSubmitRunOperator
- Parameters:
Array of Objects(RunSubmitTaskSettings) <= 100 items.
json (Any | None) –
A JSON object containing API parameters which will be passed directly to the
api/2.1/jobs/runs/submitendpoint. The other named parameters (i.e.spark_jar_task,notebook_task..) to this operator will be merged with this json dictionary if they are provided. If there are conflicts during the merge, the named parameters will take precedence and override the top level json keys. (templated)See also
For more information about templating see Jinja Templating. https://docs.databricks.com/dev-tools/api/latest/jobs.html#operation/JobsRunsSubmit
spark_jar_task (dict[str, str] | None) –
The main class and parameters for the JAR task. Note that the actual JAR is specified in the
libraries. EITHERspark_jar_taskORnotebook_taskORspark_python_taskORspark_submit_taskORpipeline_taskORdbt_taskshould be specified. This field will be templated.notebook_task (dict[str, str] | None) –
The notebook path and parameters for the notebook task. EITHER
spark_jar_taskORnotebook_taskORspark_python_taskORspark_submit_taskORpipeline_taskORdbt_taskshould be specified. This field will be templated.spark_python_task (dict[str, str | list[str]] | None) –
The python file path and parameters to run the python file with. EITHER
spark_jar_taskORnotebook_taskORspark_python_taskORspark_submit_taskORpipeline_taskORdbt_taskshould be specified. This field will be templated.spark_submit_task (dict[str, list[str]] | None) –
Parameters needed to run a spark-submit command. EITHER
spark_jar_taskORnotebook_taskORspark_python_taskORspark_submit_taskORpipeline_taskORdbt_taskshould be specified. This field will be templated.pipeline_task (dict[str, str] | None) –
Parameters needed to execute a Delta Live Tables pipeline task. The provided dictionary must contain at least
pipeline_idfield! EITHERspark_jar_taskORnotebook_taskORspark_python_taskORspark_submit_taskORpipeline_taskORdbt_taskshould be specified. This field will be templated.dbt_task (dict[str, str | list[str]] | None) – Parameters needed to execute a dbt task. The provided dictionary must contain at least the
commandsfield and thegit_sourceparameter also needs to be set. EITHERspark_jar_taskORnotebook_taskORspark_python_taskORspark_submit_taskORpipeline_taskORdbt_taskshould be specified. This field will be templated.new_cluster (dict[str, object] | None) –
Specs for a new cluster on which this task will be run. EITHER
new_clusterORexisting_cluster_idshould be specified (except whenpipeline_taskis used). This field will be templated.existing_cluster_id (str | None) – ID for existing cluster on which to run this task. EITHER
new_clusterORexisting_cluster_idshould be specified (except whenpipeline_taskis used). This field will be templated.libraries (list[dict[str, Any]] | None) –
Libraries which this run will use. This field will be templated.
run_name (str | None) – The run name used for this task. By default this will be set to the Airflow
task_id. Thistask_idis a required parameter of the superclassBaseOperator. This field will be templated.idempotency_token (str | None) – an optional token that can be used to guarantee the idempotency of job run requests. If a run with the provided token already exists, the request does not create a new run but returns the ID of the existing run instead. This token must have at most 64 characters.
access_control_list (list[dict[str, str]] | None) – optional list of dictionaries representing Access Control List (ACL) for a given job run. Each dictionary consists of following field - specific subject (
user_namefor users, orgroup_namefor groups), andpermission_levelfor that subject. See Jobs API documentation for more details.wait_for_termination (bool) – if we should wait for termination of the job run.
Trueby default.timeout_seconds (int | None) – The timeout for this run. By default a value of 0 is used which means to have no timeout. This field will be templated.
databricks_conn_id (str) – Reference to the Databricks connection. By default and in the common case this will be
databricks_default. To use token based authentication, provide the keytokenin the extra field for the connection and create the keyhostand leave thehostfield empty. (templated)polling_period_seconds (int) – Controls the rate which we poll for the result of this run. By default the operator will poll every 30 seconds.
databricks_retry_limit (int) – Amount of times retry if the Databricks backend is unreachable. Its value must be greater than or equal to 1.
databricks_retry_delay (int) – Number of seconds to wait between retries (it might be a floating point number).
databricks_retry_args (dict[Any, Any] | None) – An optional dictionary with arguments passed to
tenacity.Retryingclass.do_xcom_push (bool) – Whether we should push run_id and run_page_url to xcom.
git_source (dict[str, str] | None) – Optional specification of a remote git repository from which supported task types are retrieved.
deferrable (bool) –
Run operator in the deferrable mode.
- template_fields: collections.abc.Sequence[str] = ('json', 'databricks_conn_id')[source]¶
- template_ext: collections.abc.Sequence[str] = ('.json-tpl',)[source]¶
- execute(context)[source]¶
Derive when creating an operator.
The main method to execute the task. Context is the same dictionary used as when rendering jinja templates.
Refer to get_template_context for more context.
- class airflow.providers.databricks.operators.databricks.DatabricksRunNowOperator(*, job_id=None, job_name=None, job_parameters=None, json=None, dbt_commands=None, notebook_params=None, python_params=None, jar_params=None, spark_submit_params=None, python_named_params=None, idempotency_token=None, databricks_conn_id='databricks_default', polling_period_seconds=30, databricks_retry_limit=3, databricks_retry_delay=1, databricks_retry_args=None, do_xcom_push=True, wait_for_termination=True, deferrable=conf.getboolean('operators', 'default_deferrable', fallback=False), repair_run=False, databricks_repair_reason_new_settings=None, cancel_previous_runs=False, **kwargs)[source]¶
Bases:
airflow.providers.databricks.version_compat.BaseOperatorRuns an existing Spark job run to Databricks using the api/2.1/jobs/run-now API endpoint.
See: https://docs.databricks.com/dev-tools/api/latest/jobs.html#operation/JobsRunNow
There are two ways to instantiate this operator.
In the first way, you can take the JSON payload that you typically use to call the
api/2.1/jobs/run-nowendpoint and pass it directly to ourDatabricksRunNowOperatorthrough thejsonparameter. For examplejson = { "job_id": 42, "job_parameters": {"dry-run": "true", "oldest-time-to-consider": "1457570074236"}, } notebook_run = DatabricksRunNowOperator(task_id="notebook_run", json=json)
Another way to accomplish the same thing is to use the named parameters of the
DatabricksRunNowOperatordirectly. Note that there is exactly one named parameter for each top level parameter in therun-nowendpoint. In this method, your code would look like this:job_id = 42 dbt_commands = ["dbt deps", "dbt seed", "dbt run"] notebook_params = {"dry-run": "true", "oldest-time-to-consider": "1457570074236"} python_params = ["douglas adams", "42"] jar_params = ["douglas adams", "42"] spark_submit_params = ["--class", "org.apache.spark.examples.SparkPi"] notebook_run = DatabricksRunNowOperator( job_id=job_id, dbt_commands=dbt_commands, notebook_params=notebook_params, python_params=python_params, jar_params=jar_params, spark_submit_params=spark_submit_params, )
In the case where both the json parameter AND the named parameters are provided, they will be merged together. If there are conflicts during the merge, the named parameters will take precedence and override the top level
jsonkeys.- Currently the named parameters that
DatabricksRunNowOperatorsupports are job_idjob_namejob_parametersjsondbt_commandsnotebook_paramspython_paramspython_named_parametersjar_paramsspark_submit_paramsidempotency_tokenrepair_rundatabricks_repair_reason_new_settingscancel_previous_runs
- Parameters:
job_id (str | None) –
the job_id of the existing Databricks job. This field will be templated.
job_name (str | None) – the name of the existing Databricks job. It must exist only one job with the specified name.
job_idandjob_nameare mutually exclusive. This field will be templated.job_parameters (dict[str, str] | None) –
A dict from keys to values that override or augment the job’s parameters for this run. Job parameters are passed to any of the job’s tasks that accept key-value parameters. Job parameters supersede
notebook_params,python_params,python_named_parameters,jar_params,spark_submit_params, and they cannot be used in combination. This field will be templated.json (Any | None) –
A JSON object containing API parameters which will be passed directly to the
api/2.1/jobs/run-nowendpoint. The other named parameters (i.e.notebook_params,spark_submit_params..) to this operator will be merged with this json dictionary if they are provided. If there are conflicts during the merge, the named parameters will take precedence and override the top level json keys. (templated)See also
For more information about templating see Jinja Templating. https://docs.databricks.com/dev-tools/api/latest/jobs.html#operation/JobsRunNow
dbt_commands (list[str] | None) –
A list containing the dbt commands to run using the dbt command line interface. This field will be templated.
notebook_params (dict[str, str] | None) –
A dict from keys to values for jobs with notebook task, e.g. “notebook_params”: {“name”: “john doe”, “age”: “35”}. The map is passed to the notebook and will be accessible through the dbutils.widgets.get function. See Widgets for more information. If not specified upon run-now, the triggered run will use the job’s base parameters. notebook_params cannot be specified in conjunction with jar_params. The json representation of this field (i.e. {“notebook_params”:{“name”:”john doe”,”age”:”35”}}) cannot exceed 10,000 bytes. This field will be templated.
python_params (list[str] | None) –
A list of parameters for jobs with python tasks, e.g. “python_params”: [“john doe”, “35”]. The parameters will be passed to python file as command line parameters. If specified upon run-now, it would overwrite the parameters specified in job setting. The json representation of this field (i.e. {“python_params”:[“john doe”,”35”]}) cannot exceed 10,000 bytes. This field will be templated.
python_named_params (dict[str, str] | None) –
A list of named parameters for jobs with python wheel tasks, e.g. “python_named_params”: {“name”: “john doe”, “age”: “35”}. If specified upon run-now, it would overwrite the parameters specified in job setting. This field will be templated.
jar_params (list[str] | None) –
A list of parameters for jobs with JAR tasks, e.g. “jar_params”: [“john doe”, “35”]. The parameters will be passed to JAR file as command line parameters. If specified upon run-now, it would overwrite the parameters specified in job setting. The json representation of this field (i.e. {“jar_params”:[“john doe”,”35”]}) cannot exceed 10,000 bytes. This field will be templated.
spark_submit_params (list[str] | None) –
A list of parameters for jobs with spark submit task, e.g. “spark_submit_params”: [”–class”, “org.apache.spark.examples.SparkPi”]. The parameters will be passed to spark-submit script as command line parameters. If specified upon run-now, it would overwrite the parameters specified in job setting. The json representation of this field cannot exceed 10,000 bytes. This field will be templated.
idempotency_token (str | None) – an optional token that can be used to guarantee the idempotency of job run requests. If a run with the provided token already exists, the request does not create a new run but returns the ID of the existing run instead. This token must have at most 64 characters.
databricks_conn_id (str) – Reference to the Databricks connection. By default and in the common case this will be
databricks_default. To use token based authentication, provide the keytokenin the extra field for the connection and create the keyhostand leave thehostfield empty. (templated)polling_period_seconds (int) – Controls the rate which we poll for the result of this run. By default, the operator will poll every 30 seconds.
databricks_retry_limit (int) – Amount of times retry if the Databricks backend is unreachable. Its value must be greater than or equal to 1.
databricks_retry_delay (int) – Number of seconds to wait between retries (it might be a floating point number).
databricks_retry_args (dict[Any, Any] | None) – An optional dictionary with arguments passed to
tenacity.Retryingclass.do_xcom_push (bool) – Whether we should push run_id and run_page_url to xcom.
wait_for_termination (bool) – if we should wait for termination of the job run.
Trueby default.deferrable (bool) – Run operator in the deferrable mode.
repair_run (bool) – Repair the databricks run in case of failure.
databricks_repair_reason_new_settings (dict[str, Any] | None) – A dict of reason and new_settings JSON object for which to repair the run. None by default. None means to repair at all cases with existing job settings otherwise check whether RunState state_message contains reason and update job settings as per new_settings using databricks partial job update endpoint (https://docs.databricks.com/api/workspace/jobs/update). If nothing is matched, then repair will not get triggered.
cancel_previous_runs (bool) – Cancel all existing running jobs before submitting new one.
- template_fields: collections.abc.Sequence[str] = ('json', 'databricks_conn_id')[source]¶
- template_ext: collections.abc.Sequence[str] = ('.json-tpl',)[source]¶
- Currently the named parameters that
- class airflow.providers.databricks.operators.databricks.DatabricksSQLStatementsOperator(statement, warehouse_id, *, catalog=None, schema=None, parameters=None, databricks_conn_id='databricks_default', polling_period_seconds=30, databricks_retry_limit=3, databricks_retry_delay=1, databricks_retry_args=None, do_xcom_push=True, wait_for_termination=True, timeout=3600, deferrable=conf.getboolean('operators', 'default_deferrable', fallback=False), **kwargs)[source]¶
Bases:
airflow.providers.databricks.utils.mixins.DatabricksSQLStatementsMixin,airflow.providers.databricks.version_compat.BaseOperatorSubmits a Databricks SQL Statement to Databricks using the api/2.0/sql/statements/ API endpoint.
See: https://docs.databricks.com/api/workspace/statementexecution
See also
For more information on how to use this operator, take a look at the guide: DatabricksSQLStatementsOperator
- Parameters:
statement (str) – The SQL statement to execute. The statement can optionally be parameterized, see parameters.
warehouse_id (str) – Warehouse upon which to execute a statement.
catalog (str | None) – Sets default catalog for statement execution, similar to USE CATALOG in SQL.
schema (str | None) – Sets default schema for statement execution, similar to USE SCHEMA in SQL.
parameters (list[dict[str, Any]] | None) –
A list of parameters to pass into a SQL statement containing parameter markers.
wait_for_termination (bool) – if we should wait for termination of the statement execution.
Trueby default.databricks_conn_id (str) – Reference to the Databricks connection. By default and in the common case this will be
databricks_default. To use token based authentication, provide the keytokenin the extra field for the connection and create the keyhostand leave thehostfield empty. (templated)polling_period_seconds (int) – Controls the rate which we poll for the result of this statement. By default the operator will poll every 30 seconds.
databricks_retry_limit (int) – Amount of times retry if the Databricks backend is unreachable. Its value must be greater than or equal to 1.
databricks_retry_delay (int) – Number of seconds to wait between retries (it might be a floating point number).
databricks_retry_args (dict[Any, Any] | None) – An optional dictionary with arguments passed to
tenacity.Retryingclass.do_xcom_push (bool) – Whether we should push statement_id to xcom.:
timeout (float) – The timeout for the Airflow task executing the SQL statement. By default a value of 3600 seconds is used.
deferrable (bool) – Run operator in the deferrable mode.
- template_fields: collections.abc.Sequence[str] = ('databricks_conn_id',)[source]¶
- template_ext: collections.abc.Sequence[str] = ('.json-tpl',)[source]¶
- class airflow.providers.databricks.operators.databricks.DatabricksTaskBaseOperator(caller='DatabricksTaskBaseOperator', databricks_conn_id='databricks_default', databricks_task_key='', databricks_retry_args=None, databricks_retry_delay=1, databricks_retry_limit=3, deferrable=conf.getboolean('operators', 'default_deferrable', fallback=False), existing_cluster_id='', job_cluster_key='', new_cluster=None, polling_period_seconds=5, wait_for_termination=True, workflow_run_metadata=None, **kwargs)[source]¶
Bases:
airflow.providers.databricks.version_compat.BaseOperator,abc.ABCBase class for operators that are run as Databricks job tasks or tasks within a Databricks workflow.
- Parameters:
caller (str) – The name of the caller operator to be used in the logs.
databricks_conn_id (str) – The name of the Airflow connection to use.
databricks_task_key (str) – An optional task_key used to refer to the task by Databricks API. By default this will be set to the hash of
dag_id + task_id.databricks_retry_args (dict[Any, Any] | None) – An optional dictionary with arguments passed to
tenacity.Retryingclass.databricks_retry_delay (int) – Number of seconds to wait between retries.
databricks_retry_limit (int) – Amount of times to retry if the Databricks backend is unreachable.
deferrable (bool) – Whether to run the operator in the deferrable mode.
existing_cluster_id (str) – ID for existing cluster on which to run this task.
job_cluster_key (str) – The key for the job cluster.
new_cluster (dict[str, Any] | None) – Specs for a new cluster on which this task will be run.
notebook_packages – A list of the Python libraries to be installed on the cluster running the notebook.
notebook_params – A dict of key-value pairs to be passed as optional params to the notebook task.
polling_period_seconds (int) – Controls the rate which we poll for the result of this notebook job run.
wait_for_termination (bool) – if we should wait for termination of the job run.
Trueby default.workflow_run_metadata (dict[str, Any] | None) – Metadata for the workflow run. This is used when the operator is used within a workflow. It is expected to be a dictionary containing the run_id and conn_id for the workflow.
- monitor_databricks_job()[source]¶
Monitor the Databricks job.
Wait for the job to terminate. If deferrable, defer the task.
- class airflow.providers.databricks.operators.databricks.DatabricksNotebookOperator(notebook_path, source, databricks_conn_id='databricks_default', databricks_retry_args=None, databricks_retry_delay=1, databricks_retry_limit=3, deferrable=conf.getboolean('operators', 'default_deferrable', fallback=False), existing_cluster_id='', job_cluster_key='', new_cluster=None, notebook_packages=None, notebook_params=None, polling_period_seconds=5, wait_for_termination=True, workflow_run_metadata=None, **kwargs)[source]¶
Bases:
DatabricksTaskBaseOperatorRuns a notebook on Databricks using an Airflow operator.
The DatabricksNotebookOperator allows users to launch and monitor notebook job runs on Databricks as Airflow tasks. It can be used as a part of a DatabricksWorkflowTaskGroup to take advantage of job clusters, which allows users to run their tasks on cheaper clusters that can be shared between tasks.
See also
For more information on how to use this operator, take a look at the guide: DatabricksNotebookOperator
- Parameters:
notebook_path (str) – The path to the notebook in Databricks.
source (str) – Optional location type of the notebook. When set to WORKSPACE, the notebook will be retrieved from the local Databricks workspace. When set to GIT, the notebook will be retrieved from a Git repository defined in git_source. If the value is empty, the task will use GIT if git_source is defined and WORKSPACE otherwise. For more information please visit https://docs.databricks.com/dev-tools/api/latest/jobs.html#operation/JobsCreate
databricks_conn_id (str) – The name of the Airflow connection to use.
databricks_retry_args (dict[Any, Any] | None) – An optional dictionary with arguments passed to
tenacity.Retryingclass.databricks_retry_delay (int) – Number of seconds to wait between retries.
databricks_retry_limit (int) – Amount of times to retry if the Databricks backend is unreachable.
deferrable (bool) – Whether to run the operator in the deferrable mode.
existing_cluster_id (str) – ID for existing cluster on which to run this task.
job_cluster_key (str) – The key for the job cluster.
new_cluster (dict[str, Any] | None) – Specs for a new cluster on which this task will be run.
notebook_packages (list[dict[str, Any]] | None) – A list of the Python libraries to be installed on the cluster running the notebook.
notebook_params (dict | None) – A dict of key-value pairs to be passed as optional params to the notebook task.
polling_period_seconds (int) – Controls the rate which we poll for the result of this notebook job run.
wait_for_termination (bool) – if we should wait for termination of the job run.
Trueby default.workflow_run_metadata (dict | None) – Metadata for the workflow run. This is used when the operator is used within a workflow. It is expected to be a dictionary containing the run_id and conn_id for the workflow.
- class airflow.providers.databricks.operators.databricks.DatabricksTaskOperator(task_config, databricks_conn_id='databricks_default', databricks_retry_args=None, databricks_retry_delay=1, databricks_retry_limit=3, deferrable=conf.getboolean('operators', 'default_deferrable', fallback=False), existing_cluster_id='', job_cluster_key='', new_cluster=None, polling_period_seconds=5, wait_for_termination=True, workflow_run_metadata=None, **kwargs)[source]¶
Bases:
DatabricksTaskBaseOperatorRuns a task on Databricks using an Airflow operator.
The DatabricksTaskOperator allows users to launch and monitor task job runs on Databricks as Airflow tasks. It can be used as a part of a DatabricksWorkflowTaskGroup to take advantage of job clusters, which allows users to run their tasks on cheaper clusters that can be shared between tasks.
See also
For more information on how to use this operator, take a look at the guide: DatabricksTaskOperator
- Parameters:
task_config (dict) – The configuration of the task to be run on Databricks.
databricks_conn_id (str) – The name of the Airflow connection to use.
databricks_retry_args (dict[Any, Any] | None) – An optional dictionary with arguments passed to
tenacity.Retryingclass.databricks_retry_delay (int) – Number of seconds to wait between retries.
databricks_retry_limit (int) – Amount of times to retry if the Databricks backend is unreachable.
deferrable (bool) – Whether to run the operator in the deferrable mode.
existing_cluster_id (str) – ID for existing cluster on which to run this task.
job_cluster_key (str) – The key for the job cluster.
new_cluster (dict[str, Any] | None) – Specs for a new cluster on which this task will be run.
polling_period_seconds (int) – Controls the rate which we poll for the result of this notebook job run.
wait_for_termination (bool) – if we should wait for termination of the job run.
Trueby default.