pingzh commented on a change in pull request #22416: URL: https://github.com/apache/airflow/pull/22416#discussion_r834650996
########## File path: airflow/providers/presto/hooks/presto.py ########## @@ -27,6 +28,33 @@ from airflow.configuration import conf from airflow.hooks.dbapi import DbApiHook from airflow.models import Connection +from airflow.utils.operator_helpers import AIRFLOW_VAR_NAME_FORMAT_MAPPING + +try: + from airflow.utils.operator_helpers import DEFAULT_FORMAT_PREFIX +except ImportError: + # This is from airflow.utils.operator_helpers, + # For the sake of provider backward compatibility, this is hardcoded if import fails + # https://github.com/apache/airflow/pull/22416#issuecomment-1075531290 + DEFAULT_FORMAT_PREFIX = 'airflow.ctx.' + + +def generate_presto_client_info() -> str: + """Return json string with dag_id, task_id, execution_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() + } + task_info = { + 'dag_id': context_var['dag_id'], Review comment: 👍 added -- 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]
