Skip to content

Conversation

@rohithreddykota
Copy link

This PR addresses a method resolution order (MRO) issue in the ClickHouse.*Operator implementations.

For example ClickHouseBranchSQLOperator, due to the current inheritance order, parameters intended for the sql.BranchSQLOperator (such as follow_task_ids_if_true, follow_task_ids_if_false, and parameters) are not being correctly processed. This results in an “Invalid arguments” error when the operator is instantiated.

Background

The operator is defined as follows:

class ClickHouseBranchSQLOperator(
    sql.BranchSQLOperator,
    ClickHouseBaseDbApiOperator,
):
    pass

Because of Python’s MRO, the init method from ClickHouseBaseDbApiOperator (or its parent, BaseSQLOperator) is encountered before sql.BranchSQLOperator.init. As a result, any branch-specific parameters are not recognized, leading to failures when those parameters are passed during instantiation.

@bryzgaloff
Copy link
Owner

Hi @rohithreddykota, thank you for your contribution!

Would it be possible to demonstrate the incorrect MRO through the tests first? This functionality is indeed not yet covered by tests: https://github.com/bryzgaloff/airflow-clickhouse-plugin/blob/master/tests/unit/operators/test_clickhouse_dbapi.py

From my understanding of how MRO works, ClickHouseBranchSQLOperator(...) should first call BranchSQLOperator's __init__, then ClickHouseBaseDbApiOperator's, followed by their parent classes. This is the intended order — the goal is to pass BranchSQLOperator-specific arguments first, while any unused ones should flow through the superclass chain. Do I miss something here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants