code: def test_exec_write_file(
      return_last,
      split_statements,
      sql,
      descriptions,
      hook_results,
      do_xcom_push,
      tmp_path,
  ):
      """
      Test the execute function in case where SQL query was successful and data is written as CSV
      """
      with patch(
          "airflow.providers.databricks.operators.databricks_sql.DatabricksSqlHook"
      ) as db_mock_class:
          path = tmp_path / "testfile"
          op = DatabricksSqlOperator(
              task_id=TASK_ID,
              sql=sql,
              output_path=os.fspath(path),
              return_last=return_last,
              do_xcom_push=do_xcom_push,
              split_statements=split_statements,
          )
          db_mock = db_mock_class.return_value
          mock_results = hook_results
          db_mock.run.return_value = mock_results
          db_mock.descriptions = descriptions
  
          op.execute(None)
          results = path.read_text().splitlines()
          # In all cases only result of last query i output as file
          assert results == ["id,value", "1,value1", "2,value2"]
          db_mock_class.assert_called_once_with(
              DEFAULT_CONN_ID,
              http_path=None,
              return_tuple=True,
              session_configuration=None,
              sql_endpoint_name=None,
              http_headers=None,
              catalog=None,
              schema=None,
              caller="DatabricksSqlOperator",
          )
          db_mock.run.assert_called_once_with(
              sql=sql,
              parameters=None,
              handler=fetch_all_handler,
              autocommit=False,
              return_last=return_last,
              split_statements=split_statements,
          )
  
file_path: airflow/tests/providers/databricks/operators/test_databricks_sql.py
imports: from __future__ import annotations
  import os
  from unittest.mock import patch
  import pytest
  from databricks.sql.types import Row
  from airflow.providers.common.sql.hooks.sql import fetch_all_handler
  from airflow.providers.databricks.operators.databricks_sql import DatabricksSqlOperator
label_desc: Use image node_id 2 for calling a global function with example usage: test_exec_write_file(return_last, split_statements, sql, descriptions, hook_results, do_xcom_push, tmp_path) without return types