mobuchowski commented on PR #44913:
URL: https://github.com/apache/airflow/pull/44913#issuecomment-2545237256

   @potiuk see that example from example: 
   
   ```
   def get_hook_lineage_collector():
       # Dataset has been renamed as Asset in 3.0
       if AIRFLOW_V_3_0_PLUS:
           from airflow.lineage.hook import get_hook_lineage_collector
   
           return get_hook_lineage_collector()
   
       # HookLineageCollector added in 2.10
       if AIRFLOW_V_2_10_PLUS:
           return _get_asset_compat_hook_lineage_collector()
   
       # For the case that airflow has not yet upgraded to 2.10 or higher,
       # but using the providers that already uses `get_hook_lineage_collector`
       class NoOpCollector:
           """
           NoOpCollector is a hook lineage collector that does nothing.
   
           It is used when you want to disable lineage collection.
           """
   
           # for providers that support asset rename
           def add_input_asset(self, *_, **__):
               pass
   
           def add_output_asset(self, *_, **__):
               pass
   
           # for providers that do not support asset rename
           def add_input_dataset(self, *_, **__):
               pass
   
           def add_output_dataset(self, *_, **__):
               pass
   
       return NoOpCollector()
   ```
   
   This could be done in a different way:
   
   ```
   # Dataset has been renamed as Asset in 3.0
   if AIRFLOW_V_3_0_PLUS:
       from airflow.lineage.hook import get_hook_lineage_collector
   
       return get_hook_lineage_collector()
   
   # HookLineageCollector added in 2.10
   elif AIRFLOW_V_2_10_PLUS:
       return _get_asset_compat_hook_lineage_collector()
   
   else:
       # For the case that airflow has not yet upgraded to 2.10 or higher,
       # but using the providers that already uses `get_hook_lineage_collector`
       def get_hook_lineage_collector():
           class NoOpCollector:
               """
               NoOpCollector is a hook lineage collector that does nothing.
   
               It is used when you want to disable lineage collection.
               """
   
               # for providers that support asset rename
               def add_input_asset(self, *_, **__):
                   pass
   
               def add_output_asset(self, *_, **__):
                   pass
   
               # for providers that do not support asset rename
               def add_input_dataset(self, *_, **__):
                   pass
   
               def add_output_dataset(self, *_, **__):
                   pass
   
           return NoOpCollector()
    ```
   
   However, it still would require parsing version variables - and this is 
pretty important since it's good chunk of a reason why common.compat exists in 
the first place. 


-- 
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]

Reply via email to