eladkal commented on code in PR #29940: URL: https://github.com/apache/airflow/pull/29940#discussion_r1160812862
########## airflow/providers/openlineage/extractors/base.py: ########## @@ -0,0 +1,106 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from __future__ import annotations + +from abc import ABC, abstractmethod + +from attrs import Factory, define + +from airflow.utils.log.logging_mixin import LoggingMixin +from openlineage.client.facet import BaseFacet +from openlineage.client.run import Dataset + + +@define +class OperatorLineage: + """Structure returned from lineage extraction.""" + + inputs: list[Dataset] = Factory(list) + outputs: list[Dataset] = Factory(list) + run_facets: dict[str, BaseFacet] = Factory(dict) + job_facets: dict[str, BaseFacet] = Factory(dict) + + +class BaseExtractor(ABC, LoggingMixin): + """ + Abstract base extractor class. + + This is used mostly to maintain support for custom extractors. + """ + + _allowed_query_params: list[str] = [] + + def __init__(self, operator): # type: ignore + super().__init__() + self.operator = operator + + @classmethod + @abstractmethod + def get_operator_classnames(cls) -> list[str]: + """ + Implement this method returning list of operators that extractor works for. + + Particularly, in Airflow 2 some operators are deprecated and simply subclass the new + implementation, for example airflow.contrib.operators.bigquery_operator.BigQueryOperator. + The BigQueryExtractor needs to work with both of them. Review Comment: Please explain this. There is no `BigQueryOperator` in the code base. Deprecated operators are backward compatible. They should not have special treatment. ########## docs/spelling_wordlist.txt: ########## @@ -161,6 +161,7 @@ BestCandidate Bigquery bigquery BigQueryHook +BigQueryOperator Review Comment: This is not needed, you should mark the place where you use is as code then the spelling check will know to treat it as such. -- 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]
