Repository: apache/superset
File: superset/db_engine_specs/base.py (Python)

Code before:

    @classmethod
    def handle_comparison_filter(
        cls, sqla_col: Any, op: str, value: Any
    ) -> BinaryExpression:
        """
        Handle comparison filter operations (=, !=, >, <, >=, <=).

        :param sqla_col: SQLAlchemy column element
        :param op: Filter operator
        :param value: Filter value
        :return: SQLAlchemy expression for the comparison filter
        """
        from superset.utils import core as utils

        if op == utils.FilterOperator.EQUALS.value:
            return sqla_col == value
        elif op == utils.FilterOperator.NOT_EQUALS.value:
            return sqla_col != value
        elif op == utils.FilterOperator.GREATER_THAN.value:
            return sqla_col > value
        elif op == utils.FilterOperator.LESS_THAN.value:
            return sqla_col < value
        elif op == utils.FilterOperator.GREATER_THAN_OR_EQUALS.value:
            return sqla_col >= value
        elif op == utils.FilterOperator.LESS_THAN_OR_EQUALS.value:
            return sqla_col <= value
        else:
            raise ValueError(f"Invalid comparison filter operator: {op}")

    @classmethod
    def handle_cursor(cls, cursor: Any, query: Query) -> None:
        """Handle a live cursor between the execute and fetchall calls

        The flow works without this method doing anything, but it allows
        for handling the cursor and updating progress information in the
        query object"""

    @classmethod
    # pylint: disable=consider-using-transaction
    def execute_with_cursor(
        cls,
        cursor: Any,
        sql: str,
        query: Query,
    ) -> None:
        """
        Trigger execution of a query and handle the resulting cursor.

        For most implementations this just makes calls to `execute` and
        `handle_cursor` consecutively, but in some engines (e.g. Trino) we may

Review comment (suggestion):
Adjust:

```suggestion
        if op == utils.FilterOperator.EQUALS:
            return sqla_col == value
        elif op == utils.FilterOperator.NOT_EQUALS:
            return sqla_col != value
        elif op == utils.FilterOperator.GREATER_THAN:
            return sqla_col > value
        elif op == utils.FilterOperator.LESS_THAN:
            return sqla_col < value
        elif op == utils.FilterOperator.GREATER_THAN_OR_EQUALS:
            return sqla_col >= value
        elif op == utils.FilterOperator.LESS_THAN_OR_EQUALS:
```

Code after:
        elif op == utils.FilterOperator.IS_NOT_NULL:
            return sqla_col.isnot(None)
        else:
            raise ValueError(f"Invalid null filter operator: {op}")

    @classmethod
    def handle_comparison_filter(
        cls, sqla_col: Any, op: utils.FilterOperator, value: Any
    ) -> BinaryExpression:
        """
        Handle comparison filter operations (=, !=, >, <, >=, <=).

        :param sqla_col: SQLAlchemy column element
        :param op: Filter operator
        :param value: Filter value
        :return: SQLAlchemy expression for the comparison filter
        """
        from superset.utils import core as utils

        if op == utils.FilterOperator.EQUALS:
            return sqla_col == value
        elif op == utils.FilterOperator.NOT_EQUALS:
            return sqla_col != value
        elif op == utils.FilterOperator.GREATER_THAN:
            return sqla_col > value
        elif op == utils.FilterOperator.LESS_THAN:
            return sqla_col < value
        elif op == utils.FilterOperator.GREATER_THAN_OR_EQUALS:
            return sqla_col >= value
        elif op == utils.FilterOperator.LESS_THAN_OR_EQUALS:
            return sqla_col <= value
        else:
            raise ValueError(f"Invalid comparison filter operator: {op}")

    @classmethod
    def handle_cursor(cls, cursor: Any, query: Query) -> None:
        """Handle a live cursor between the execute and fetchall calls

        The flow works without this method doing anything, but it allows
        for handling the cursor and updating progress information in the
        query object"""

    @classmethod
    # pylint: disable=consider-using-transaction
    def execute_with_cursor(
        cls,
        cursor: Any,
        sql: str,
        query: Query,
    ) -> None:
        """