prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Exception logging success function instead of failure
  https://github.com/apache/airflow/blob/fdd9b6f65b608c516b8a062b058972d9a45ec9e3/airflow/sensors/sql_sensor.py#L97
  
  
  
  </issue>
  <code>
  [start of airflow/sensors/sql_sensor.py]
  1 #
  2 # Licensed to the Apache Software Foundation (ASF) under one
  3 # or more contributor license agreements.  See the NOTICE file
  4 # distributed with this work for additional information
  5 # regarding copyright ownership.  The ASF licenses this file
  6 # to you under the Apache License, Version 2.0 (the
  7 # "License"); you may not use this file except in compliance
  8 # with the License.  You may obtain a copy of the License at
  9 #
  10 #   http://www.apache.org/licenses/LICENSE-2.0
  11 #
  12 # Unless required by applicable law or agreed to in writing,
  13 # software distributed under the License is distributed on an
  14 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15 # KIND, either express or implied.  See the License for the
  16 # specific language governing permissions and limitations
  17 # under the License.
  18 
  19 from typing import Iterable
  20 
  21 from airflow.exceptions import AirflowException
  22 from airflow.hooks.base_hook import BaseHook
  23 from airflow.sensors.base_sensor_operator import BaseSensorOperator
  24 from airflow.utils.decorators import apply_defaults
  25 
  26 
  27 class SqlSensor(BaseSensorOperator):
  28     """
  29     Runs a sql statement repeatedly until a criteria is met. It will keep trying until
  30     success or failure criteria are met, or if the first cell is not in (0, '0', '', None).
  31     Optional success and failure callables are called with the first cell returned as the argument.
  32     If success callable is defined the sensor will keep retrying until the criteria is met.
  33     If failure callable is defined and the criteria is met the sensor will raise AirflowException.
  34     Failure criteria is evaluated before success criteria. A fail_on_empty boolean can also
  35     be passed to the sensor in which case it will fail if no rows have been returned
  36 
  37     :param conn_id: The connection to run the sensor against
  38     :type conn_id: str
  39     :param sql: The sql to run. To pass, it needs to return at least one cell
  40         that contains a non-zero / empty string value.
  41     :type sql: str
  42     :param parameters: The parameters to render the SQL query with (optional).
  43     :type parameters: dict or iterable
  44     :param success: Success criteria for the sensor is a Callable that takes first_cell
  45         as the only argument, and returns a boolean (optional).
  46     :type: success: Optional<Callable[[Any], bool]>
  47     :param failure: Failure criteria for the sensor is a Callable that takes first_cell
  48         as the only argument and return a boolean (optional).
  49     :type: failure: Optional<Callable[[Any], bool]>
  50     :param fail_on_empty: Explicitly fail on no rows returned.
  51     :type: fail_on_empty: bool
  52     """
  53 
  54     template_fields: Iterable[str] = ('sql',)
  55     template_ext: Iterable[str] = (
  56         '.hql',
  57         '.sql',
  58     )
  59     ui_color = '#7c7287'
  60 
  61     @apply_defaults
  62     def __init__(
  63         self, *, conn_id, sql, parameters=None, success=None, failure=None, fail_on_empty=False, **kwargs
  64     ):
  65         self.conn_id = conn_id
  66         self.sql = sql
  67         self.parameters = parameters
  68         self.success = success
  69         self.failure = failure
  70         self.fail_on_empty = fail_on_empty
  71         super().__init__(**kwargs)
  72 
  73     def _get_hook(self):
  74         conn = BaseHook.get_connection(self.conn_id)
  75 
  76         allowed_conn_type = {
  77             'google_cloud_platform',
  78             'jdbc',
  79             'mssql',
  80             'mysql',
  81             'odbc',
  82             'oracle',
  83             'postgres',
  84             'presto',
  85             'snowflake',
  86             'sqlite',
  87             'vertica',
  88         }
  89         if conn.conn_type not in allowed_conn_type:
  90             raise AirflowException(
  91                 "The connection type is not supported by SqlSensor. "
  92                 + "Supported connection types: {}".format(list(allowed_conn_type))
  93             )
  94         return conn.get_hook()
  95 
  96     def poke(self, context):
  97         hook = self._get_hook()
  98 
  99         self.log.info('Poking: %s (with parameters %s)', self.sql, self.parameters)
  100         records = hook.get_records(self.sql, self.parameters)
  101         if not records:
  102             if self.fail_on_empty:
  103                 raise AirflowException("No rows returned, raising as per fail_on_empty flag")
  104             else:
  105                 return False
  106         first_cell = records[0][0]
  107         if self.failure is not None:
  108             if callable(self.failure):
  109                 if self.failure(first_cell):
  110                     raise AirflowException(f"Failure criteria met. self.failure({first_cell}) returned True")
  111             else:
  112                 raise AirflowException(f"self.failure is present, but not callable -> {self.success}")
  113         if self.success is not None:
  114             if callable(self.success):
  115                 return self.success(first_cell)
  116             else:
  117                 raise AirflowException(f"self.success is present, but not callable -> {self.success}")
  118         return bool(first_cell)
  119
  [end of airflow/sensors/sql_sensor.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/airflow/sensors/sql_sensor.py b/airflow/sensors/sql_sensor.py
  --- a/airflow/sensors/sql_sensor.py
  +++ b/airflow/sensors/sql_sensor.py
  @@ -109,7 +109,7 @@
                   if self.failure(first_cell):
                       raise AirflowException(f"Failure criteria met. self.failure({first_cell}) returned True")
               else:
  -                raise AirflowException(f"self.failure is present, but not callable -> {self.success}")
  +                raise AirflowException(f"self.failure is present, but not callable -> {self.failure}")
           if self.success is not None:
               if callable(self.success):
                   return self.success(first_cell)
  
verification_info: {"golden_diff": "diff --git a/airflow/sensors/sql_sensor.py b/airflow/sensors/sql_sensor.py\n--- a/airflow/sensors/sql_sensor.py\n+++ b/airflow/sensors/sql_sensor.py\n@@ -109,7 +109,7 @@\n                 if self.failure(first_cell):\n                     raise AirflowException(f\"Failure criteria met. self.failure({first_cell}) returned True\")\n             else:\n-                raise AirflowException(f\"self.failure is present, but not callable -> {self.success}\")\n+                raise AirflowException(f\"self.failure is present, but not callable -> {self.failure}\")\n         if self.success is not None:\n             if callable(self.success):\n                 return self.success(first_cell)\n", "issue": "Exception logging success function instead of failure\nhttps://github.com/apache/airflow/blob/fdd9b6f65b608c516b8a062b058972d9a45ec9e3/airflow/sensors/sql_sensor.py#L97\r\n\r\n\n", "before_files": [{"content": "#\n# Licensed to the Apache Software Foundation (ASF) under one\n# or more contributor license agreements.  See the NOTICE file\n# distributed with this work for additional information\n# regarding copyright ownership.  The ASF licenses this file\n# to you under the Apache License, Version 2.0 (the\n# \"License\"); you may not use this file except in compliance\n# with the License.  You may obtain a copy of the License at\n#\n#   http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n# KIND, either express or implied.  See the License for the\n# specific language governing permissions and limitations\n# under the License.\n\nfrom typing import Iterable\n\nfrom airflow.exceptions import AirflowException\nfrom airflow.hooks.base_hook import BaseHook\nfrom airflow.sensors.base_sensor_operator import BaseSensorOperator\nfrom airflow.utils.decorators import apply_defaults\n\n\nclass SqlSensor(BaseSensorOperator):\n    \"\"\"\n    Runs a sql statement repeatedly until a criteria is met. It will keep trying until\n    success or failure criteria are met, or if the first cell is not in (0, '0', '', None).\n    Optional success and failure callables are called with the first cell returned as the argument.\n    If success callable is defined the sensor will keep retrying until the criteria is met.\n    If failure callable is defined and the criteria is met the sensor will raise AirflowException.\n    Failure criteria is evaluated before success criteria. A fail_on_empty boolean can also\n    be passed to the sensor in which case it will fail if no rows have been returned\n\n    :param conn_id: The connection to run the sensor against\n    :type conn_id: str\n    :param sql: The sql to run. To pass, it needs to return at least one cell\n        that contains a non-zero / empty string value.\n    :type sql: str\n    :param parameters: The parameters to render the SQL query with (optional).\n    :type parameters: dict or iterable\n    :param success: Success criteria for the sensor is a Callable that takes first_cell\n        as the only argument, and returns a boolean (optional).\n    :type: success: Optional<Callable[[Any], bool]>\n    :param failure: Failure criteria for the sensor is a Callable that takes first_cell\n        as the only argument and return a boolean (optional).\n    :type: failure: Optional<Callable[[Any], bool]>\n    :param fail_on_empty: Explicitly fail on no rows returned.\n    :type: fail_on_empty: bool\n    \"\"\"\n\n    template_fields: Iterable[str] = ('sql',)\n    template_ext: Iterable[str] = (\n        '.hql',\n        '.sql',\n    )\n    ui_color = '#7c7287'\n\n    @apply_defaults\n    def __init__(\n        self, *, conn_id, sql, parameters=None, success=None, failure=None, fail_on_empty=False, **kwargs\n    ):\n        self.conn_id = conn_id\n        self.sql = sql\n        self.parameters = parameters\n        self.success = success\n        self.failure = failure\n        self.fail_on_empty = fail_on_empty\n        super().__init__(**kwargs)\n\n    def _get_hook(self):\n        conn = BaseHook.get_connection(self.conn_id)\n\n        allowed_conn_type = {\n            'google_cloud_platform',\n            'jdbc',\n            'mssql',\n            'mysql',\n            'odbc',\n            'oracle',\n            'postgres',\n            'presto',\n            'snowflake',\n            'sqlite',\n            'vertica',\n        }\n        if conn.conn_type not in allowed_conn_type:\n            raise AirflowException(\n                \"The connection type is not supported by SqlSensor. \"\n                + \"Supported connection types: {}\".format(list(allowed_conn_type))\n            )\n        return conn.get_hook()\n\n    def poke(self, context):\n        hook = self._get_hook()\n\n        self.log.info('Poking: %s (with parameters %s)', self.sql, self.parameters)\n        records = hook.get_records(self.sql, self.parameters)\n        if not records:\n            if self.fail_on_empty:\n                raise AirflowException(\"No rows returned, raising as per fail_on_empty flag\")\n            else:\n                return False\n        first_cell = records[0][0]\n        if self.failure is not None:\n            if callable(self.failure):\n                if self.failure(first_cell):\n                    raise AirflowException(f\"Failure criteria met. self.failure({first_cell}) returned True\")\n            else:\n                raise AirflowException(f\"self.failure is present, but not callable -> {self.success}\")\n        if self.success is not None:\n            if callable(self.success):\n                return self.success(first_cell)\n            else:\n                raise AirflowException(f\"self.success is present, but not callable -> {self.success}\")\n        return bool(first_cell)\n", "path": "airflow/sensors/sql_sensor.py"}]}