Skip to content

Commit 1fd66f1

Browse files
authored
Provider Migration: Update Apache Kylin for Airflow 3.0 compatibility (#52572)
1 parent bf1a6b6 commit 1fd66f1

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

providers/apache/kylin/src/airflow/providers/apache/kylin/operators/kylin_cube.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
from kylinpy import kylinpy
2626

2727
from airflow.exceptions import AirflowException
28-
from airflow.models import BaseOperator
2928
from airflow.providers.apache.kylin.hooks.kylin import KylinHook
29+
from airflow.providers.apache.kylin.version_compat import BaseOperator
3030

3131
if TYPE_CHECKING:
3232
from airflow.utils.context import Context
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
#
18+
# NOTE! THIS FILE IS COPIED MANUALLY IN OTHER PROVIDERS DELIBERATELY TO AVOID ADDING UNNECESSARY
19+
# DEPENDENCIES BETWEEN PROVIDERS. IF YOU WANT TO ADD CONDITIONAL CODE IN YOUR PROVIDER THAT DEPENDS
20+
# ON AIRFLOW VERSION, PLEASE COPY THIS FILE TO THE ROOT PACKAGE OF YOUR PROVIDER AND IMPORT
21+
# THOSE CONSTANTS FROM IT RATHER THAN IMPORTING THEM FROM ANOTHER PROVIDER OR TEST CODE
22+
#
23+
from __future__ import annotations
24+
25+
26+
def get_base_airflow_version_tuple() -> tuple[int, int, int]:
27+
from packaging.version import Version
28+
29+
from airflow import __version__
30+
31+
airflow_version = Version(__version__)
32+
return airflow_version.major, airflow_version.minor, airflow_version.micro
33+
34+
35+
AIRFLOW_V_3_0_PLUS = get_base_airflow_version_tuple() >= (3, 0, 0)
36+
37+
if AIRFLOW_V_3_0_PLUS:
38+
from airflow.sdk import BaseOperator
39+
else:
40+
from airflow.models import BaseOperator # type: ignore[no-redef]
41+
42+
__all__ = [
43+
"AIRFLOW_V_3_0_PLUS",
44+
"BaseOperator",
45+
]

0 commit comments

Comments
 (0)