uranusjr commented on code in PR #43902:
URL: https://github.com/apache/airflow/pull/43902#discussion_r1841529728
##########
providers/src/airflow/providers/presto/hooks/presto.py:
##########
@@ -22,32 +22,38 @@
from typing import TYPE_CHECKING, Any, Iterable, Mapping, TypeVar
import prestodb
+from packaging.version import Version
from prestodb.exceptions import DatabaseError
from prestodb.transaction import IsolationLevel
+from airflow import __version__ as airflow_version
from airflow.configuration import conf
from airflow.exceptions import AirflowException
from airflow.providers.common.sql.hooks.sql import DbApiHook
from airflow.utils.operator_helpers import AIRFLOW_VAR_NAME_FORMAT_MAPPING,
DEFAULT_FORMAT_PREFIX
+AIRFLOW_VERSION = Version(airflow_version)
+AIRFLOW_V_3_0_PLUS = Version(AIRFLOW_VERSION.base_version) >= Version("3.0.0")
+
if TYPE_CHECKING:
from airflow.models import Connection
T = TypeVar("T")
def generate_presto_client_info() -> str:
- """Return json string with dag_id, task_id, execution_date and
try_number."""
+ """Return json string with dag_id, task_id, logical_date and try_number."""
context_var = {
format_map["default"].replace(DEFAULT_FORMAT_PREFIX, ""):
os.environ.get(
format_map["env_var_format"], ""
)
for format_map in AIRFLOW_VAR_NAME_FORMAT_MAPPING.values()
}
+ date_key = "logical_date" if AIRFLOW_V_3_0_PLUS else "execution_date"
task_info = {
"dag_id": context_var["dag_id"],
"task_id": context_var["task_id"],
- "execution_date": context_var["execution_date"],
+ date_key: context_var["logical_date"] if AIRFLOW_V_3_0_PLUS else
context_var["execution_date"],
Review Comment:
```suggestion
date_key: context_var["logical_date"],
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]