Airflow Operators and Hooks
#?????????????????? and #?????????? are two of the basic concepts of #??????????????.
here is a brief explanation of them and use cases:
?? ??????????????????
?? ??????????
领英推荐
?? ???????? ???????????????????? ?????????? ???? ???????????? ?????????????????? ???????? ?????????? ??????:
?? When we want to define a simple task that performs a single operation on an external system or service, such as running a SQL query on a database, copying a file to a cloud storage, sending an email notification, etc. In this case, we can use one of the built-in operators that Airflow provides for various external systems or services.
?? When we want to define a custom task that involves some logic or processing before or after performing an operation on an external system or service, such as validating data quality, applying transformations, generating reports, etc. In this case, we can create our own operator by subclassing the BaseOperator or one of its existing subclasses.
?? ???????? ???????????????????? ?????????? ???? ???????????? ?????????? ???????? ?????????????????? ??????:
?? When we want to perform multiple or complex operations on an external system or service within a single task, such as fetching data from multiple sources, performing bulk operations, executing transactions, etc. In this case, we can use one of the built-in hooks that Airflow provides for various external systems or services, or create our own hook by subclassing the BaseHook.
?? When we want to share data or state between tasks that interact with the same external system or service, such as passing query results, file names, connection objects, etc. In this case, we can use the #XCom mechanism that Airflow provides for cross-communication between tasks, and use hooks to push or pull data or state to or from XCom.