You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "kacpermuda (via GitHub)" <gi...@apache.org> on 2024/12/12 12:58:34 UTC
[PR] feat: Add CLL to OpenLineage in BigQueryInsertJobOperator [airflow]
kacpermuda opened a new pull request, #44872:
URL: https://github.com/apache/airflow/pull/44872
<!--
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.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
BigQueryInsertJobOperator already support OpenLineage for QUERY type jobs, but it lacks Column Level Lineage (CLL). This PR introduces CLL (Column-Level Lineage) to this operator based on SQL parsing, which can be useful in straightforward scenarios. However, since SQL parsing alone might not always provide all the details (e.g. in SQL query we can reference table only by table name, or dataset.table without the project_id), checks have been implemented to ensure accurate lineage. As a result CLL may not be included when there is uncertainty about its correctness.
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: Add CLL to OpenLineage in BigQueryInsertJobOperator [airflow]
Posted by "mobuchowski (via GitHub)" <gi...@apache.org>.
mobuchowski merged PR #44872:
URL: https://github.com/apache/airflow/pull/44872
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: Add CLL to OpenLineage in BigQueryInsertJobOperator [airflow]
Posted by "mobuchowski (via GitHub)" <gi...@apache.org>.
mobuchowski commented on code in PR #44872:
URL: https://github.com/apache/airflow/pull/44872#discussion_r1886874140
##########
providers/src/airflow/providers/google/cloud/openlineage/mixins.py:
##########
@@ -167,6 +211,21 @@ def _deduplicate_outputs(self, outputs: list[OutputDataset | None]) -> list[Outp
# if the rowCount or size can be summed together.
if single_output.outputFacets:
single_output.outputFacets.pop("outputStatistics", None)
+
+ # If both outputs contain Column Level Lineage Facet - merge the facets
Review Comment:
When can this be true?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: Add CLL to OpenLineage in BigQueryInsertJobOperator [airflow]
Posted by "kacpermuda (via GitHub)" <gi...@apache.org>.
kacpermuda commented on code in PR #44872:
URL: https://github.com/apache/airflow/pull/44872#discussion_r1887989193
##########
providers/src/airflow/providers/google/cloud/openlineage/mixins.py:
##########
@@ -167,6 +211,21 @@ def _deduplicate_outputs(self, outputs: list[OutputDataset | None]) -> list[Outp
# if the rowCount or size can be summed together.
if single_output.outputFacets:
single_output.outputFacets.pop("outputStatistics", None)
+
+ # If both outputs contain Column Level Lineage Facet - merge the facets
Review Comment:
When bigquery receives two or more statements in a query it treats it as a SCRIPT type job, and executes each statement in a separate child job. In that case, we extract CLL per child job, parsing the exact part of the whole query that run.
If we submit the following query to BQ, it will execute 3 child jobs and we will receive `my-project.test.new_table` 3 times with different CLL, so in order to get the whole picture we need to merge it.
```
CREATE OR REPLACE TABLE `my-project.test.new_table` AS
SELECT
id,
name,
age
FROM
`my-project.test.source`;
INSERT INTO `my-project.test.new_table`
SELECT
id,
name,
age
FROM
`my-project.test.import_table`;
INSERT INTO `new_table`
SELECT
NULL,
name,
age
FROM
`copy_result`;
```
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: Add CLL to OpenLineage in BigQueryInsertJobOperator [airflow]
Posted by "kacpermuda (via GitHub)" <gi...@apache.org>.
kacpermuda commented on PR #44872:
URL: https://github.com/apache/airflow/pull/44872#issuecomment-2563782281
PR is ready to be merged, there is some unrelated flaky test that makes TestLocalExecutor timeout.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org