class_docstr: Sensor to detect the presence of table partitions in Databricks.
  
  :param databricks_conn_id: Reference to :ref:`Databricks
      connection id<howto/connection:databricks>` (templated), defaults to
      DatabricksSqlHook.default_conn_name.
  :param sql_warehouse_name: Optional name of Databricks SQL warehouse. If not specified, ``http_path``
      must be provided as described below, defaults to None
  :param http_path: Optional string specifying HTTP path of Databricks SQL warehouse or All Purpose cluster.
      If not specified, it should be either specified in the Databricks connection's
      extra parameters, or ``sql_warehouse_name`` must be specified.
  :param session_configuration: An optional dictionary of Spark session parameters. If not specified,
      it could be specified in the Databricks connection's extra parameters, defaults to None
  :param http_headers: An optional list of (k, v) pairs
      that will be set as HTTP headers on every request. (templated).
  :param catalog: An optional initial catalog to use.
      Requires Databricks Runtime version 9.0+ (templated), defaults to ""
  :param schema: An optional initial schema to use.
      Requires Databricks Runtime version 9.0+ (templated), defaults to "default"
  :param table_name: Name of the table to check partitions.
  :param partitions: Name of the partitions to check.
      Example: {"date": "2023-01-03", "name": ["abc", "def"]}
  :param partition_operator: Optional comparison operator for partitions, such as >=.
  :param handler: Handler for DbApiHook.run() to return results, defaults to fetch_all_handler
  :param client_parameters: Additional parameters internal to Databricks SQL connector parameters.
class_docstr_tok: ["Sensor","to","detect","the","presence","of","table","partitions","in","Databricks",".",":","param","databricks_conn_id",":","Reference","to",":","ref",":","`","Databricks","connection","id","<","howto\/connection",":","databricks",">","`","(","templated",")",",","defaults","to","DatabricksSqlHook.default_conn_name",".",":","param","sql_warehouse_name",":","Optional","name","of","Databricks","SQL","warehouse",".","If","not","specified",",","``","http_path","``","must","be","provided","as","described","below",",","defaults","to","None",":","param","http_path",":","Optional","string","specifying","HTTP","path","of","Databricks","SQL","warehouse","or","All","Purpose","cluster",".","If","not","specified",",","it","should","be","either","specified","in","the","Databricks","connection's","extra","parameters",",","or","``","sql_warehouse_name","``","must","be","specified",".",":","param","session_configuration",":","An","optional","dictionary","of","Spark","session","parameters",".","If","not","specified",",","it","could","be","specified","in","the","Databricks","connection","'s","extra","parameters",",","defaults","to","None",":","param","http_headers",":","An","optional","list","of","(","k",",","v",")","pairs","that","will","be","set","as","HTTP","headers","on","every","request",".","(","templated",")",".",":","param","catalog",":","An","optional","initial","catalog","to","use",".","Requires","Databricks","Runtime","version","9.0+","(","templated",")",",","defaults","to","``","''",":","param","schema",":","An","optional","initial","schema","to","use",".","Requires","Databricks","Runtime","version","9.0+","(","templated",")",",","defaults","to","``","default","''",":","param","table_name",":","Name","of","the","table","to","check","partitions",".",":","param","partitions",":","Name","of","the","partitions","to","check",".","Example",":","{","``","date","''",":","``","2023-01-03","''",",","``","name","''",":","[","``","abc","''",",","``","def","''","]","}",":","param","partition_operator",":","Optional","comparison","operator","for","partitions",",","such","as",">","=",".",":","param","handler",":","Handler","for","DbApiHook.run","(",")","to","return","results",",","defaults","to","fetch_all_handler",":","param","client_parameters",":","Additional","parameters","internal","to","Databricks","SQL","connector","parameters","."]
docstr: Query the table for available partitions.
  
  Generates the SQL query based on the partition data types.
      * For a list, it prepares the SQL in the format:
          column_name in (value1, value2,...)
      * For a numeric type, it prepares the format:
          column_name =(or other provided operator such as >=) value
      * For a date type, it prepares the format:
          column_name =(or other provided operator such as >=) value
  Once the filter predicates have been generated like above, the query
  is prepared to be executed using the prefix and suffix supplied, which are:
  "SELECT 1 FROM {_fully_qualified_table_name} WHERE" and "LIMIT 1".
docstr_tok: ["Query","the","table","for","available","partitions",".","Generates","the","SQL","query","based","on","the","partition","data","types",".","*","For","a","list",",","it","prepares","the","SQL","in","the","format",":","column_name","in","(","value1",",","value2",",","...",")","*","For","a","numeric","type",",","it","prepares","the","format",":","column_name","=","(","or","other","provided","operator","such","as",">","=",")","value","*","For","a","date","type",",","it","prepares","the","format",":","column_name","=","(","or","other","provided","operator","such","as",">","=",")","value","Once","the","filter","predicates","have","been","generated","like","above",",","the","query","is","prepared","to","be","executed","using","the","prefix","and","suffix","supplied",",","which","are",":","''","SELECT","1","FROM","{","_fully_qualified_table_name","}","WHERE","''","and","``","LIMIT","1","''","."]
code: def _generate_partition_query(
      self,
      prefix: str,
      suffix: str,
      joiner_val: str,
      table_name: str,
      opts: dict[str, str] | None = None,
      escape_key: bool = False,
  ) -> str:
      """
      Query the table for available partitions.
  
      Generates the SQL query based on the partition data types.
          * For a list, it prepares the SQL in the format:
              column_name in (value1, value2,...)
          * For a numeric type, it prepares the format:
              column_name =(or other provided operator such as >=) value
          * For a date type, it prepares the format:
              column_name =(or other provided operator such as >=) value
      Once the filter predicates have been generated like above, the query
      is prepared to be executed using the prefix and suffix supplied, which are:
      "SELECT 1 FROM {_fully_qualified_table_name} WHERE" and "LIMIT 1".
      """
      partition_columns = self._sql_sensor(
          f"DESCRIBE DETAIL {table_name}"
      )[0][7]
      self.log.debug("Partition columns: %s", partition_columns)
      if len(partition_columns) < 1:
          # TODO: remove this if block when min_airflow_version is set to higher than 2.7.1
          message = f"Table {table_name} does not have partitions"
          if self.soft_fail:
              raise AirflowSkipException(message)
          raise AirflowException(message)
  
      formatted_opts = ""
      if opts:
          output_list = []
          for partition_col, partition_value in opts.items():
              if escape_key:
                  partition_col = self.escaper.escape_item(
                      partition_col
                  )
              if partition_col in partition_columns:
                  if isinstance(partition_value, list):
                      output_list.append(
                          f"""{partition_col} in {tuple(partition_value)}"""
                      )
                      self.log.debug(
                          "List formatting for partitions: %s",
                          output_list,
                      )
                  if isinstance(partition_value, (int, float, complex)):
                      output_list.append(
                          f"""{partition_col}{self.partition_operator}{self.escaper.escape_item(partition_value)}"""
                      )
                  if isinstance(partition_value, (str, datetime)):
                      output_list.append(
                          f"""{partition_col}{self.partition_operator}{self.escaper.escape_item(partition_value)}"""
                      )
              else:
                  # TODO: remove this if block when min_airflow_version is set to higher than 2.7.1
                  message = f"Column {partition_col} not part of table partitions: {partition_columns}"
                  if self.soft_fail:
                      raise AirflowSkipException(message)
                  raise AirflowException(message)
      else:
          # Raises exception if the table does not have any partitions.
          # TODO: remove this if block when min_airflow_version is set to higher than 2.7.1
          message = "No partitions specified to check with the sensor."
          if self.soft_fail:
              raise AirflowSkipException(message)
          raise AirflowException(message)
      formatted_opts = (
          f"{prefix} {joiner_val.join(output_list)} {suffix}"
      )
      self.log.debug("Formatted options: %s", formatted_opts)
  
      return formatted_opts.strip()
  
file_path: airflow/airflow/providers/databricks/sensors/databricks_partition.py
imports: from __future__ import annotations
  from datetime import datetime
  from functools import cached_property
  from typing import TYPE_CHECKING, Any, Callable, Sequence
  from databricks.sql.utils import ParamEscaper
  from airflow.exceptions import AirflowException, AirflowSkipException
  from airflow.providers.common.sql.hooks.sql import fetch_all_handler
  from airflow.providers.databricks.hooks.databricks_sql import DatabricksSqlHook
  from airflow.sensors.base import BaseSensorOperator
label_desc: Use image node_id 5 for calling the DatabricksPartitionSensor obj's underlying member method code with example usage: obj._generate_partition_query(prefix, suffix, joiner_val, table_name, opts, escape_key) and returns: formatted_opts