You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "JDarDagran (via GitHub)" <gi...@apache.org> on 2023/07/28 09:03:34 UTC

[GitHub] [airflow] JDarDagran opened a new pull request, #32910: openlineage, trino: add OpenLineage support for Trino.

JDarDagran opened a new pull request, #32910:
URL: https://github.com/apache/airflow/pull/32910

   <!--
    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.
    -->
   
    This PR adds OpenLineage support for TrinoOperator.


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


[GitHub] [airflow] potiuk merged pull request #32910: openlineage, trino: add OpenLineage support for Trino.

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #32910:
URL: https://github.com/apache/airflow/pull/32910


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


[GitHub] [airflow] mobuchowski commented on a diff in pull request #32910: openlineage, trino: add OpenLineage support for Trino.

Posted by "mobuchowski (via GitHub)" <gi...@apache.org>.
mobuchowski commented on code in PR #32910:
URL: https://github.com/apache/airflow/pull/32910#discussion_r1284668277


##########
airflow/providers/openlineage/utils/sql.py:
##########
@@ -155,11 +155,17 @@ def create_information_schema_query(
     metadata = MetaData(sqlalchemy_engine)
     select_statements = []
     for db, schema_mapping in tables_hierarchy.items():
-        schema, table_name = information_schema_table_name.split(".")
         if db:
-            schema = f"{db}.{schema}"
+            schema = db

Review Comment:
   Does this mean `schema` is `database schema` in Oracle meaning here, not `schema of a database`? Would be nice to document this if true - this is cause of many errors usually.



##########
airflow/providers/trino/hooks/trino.py:
##########
@@ -233,3 +233,32 @@ def _serialize_cell(cell: Any, conn: Connection | None = None) -> Any:
         :return: The cell
         """
         return cell
+
+    def get_openlineage_database_info(self, connection):
+        """Returns Trino specific information for OpenLineage."""
+        from airflow.providers.openlineage.sqlparser import DatabaseInfo
+
+        return DatabaseInfo(
+            scheme="trino",
+            authority=DbApiHook.get_openlineage_authority_part(
+                connection, default_port=trino.constants.DEFAULT_PORT
+            ),
+            information_schema_columns=[
+                "table_schema",
+                "table_name",
+                "column_name",
+                "ordinal_position",
+                "data_type",
+                "table_catalog",
+            ],
+            database=connection.extra_dejson.get("catalog", "hive"),
+            is_information_schema_cross_db=True,
+        )
+
+    def get_openlineage_database_dialect(self, _):
+        """Returns database dialect."""
+        return "trino"
+
+    def get_openlineage_default_schema(self):
+        """MySQL has no concept of schema."""

Review Comment:
   ```suggestion
           """Trino has no concept of schema."""
   ```



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


[GitHub] [airflow] JDarDagran commented on a diff in pull request #32910: openlineage, trino: add OpenLineage support for Trino.

Posted by "JDarDagran (via GitHub)" <gi...@apache.org>.
JDarDagran commented on code in PR #32910:
URL: https://github.com/apache/airflow/pull/32910#discussion_r1304066403


##########
airflow/providers/openlineage/utils/sql.py:
##########
@@ -155,11 +155,17 @@ def create_information_schema_query(
     metadata = MetaData(sqlalchemy_engine)
     select_statements = []
     for db, schema_mapping in tables_hierarchy.items():
-        schema, table_name = information_schema_table_name.split(".")
         if db:
-            schema = f"{db}.{schema}"
+            schema = db

Review Comment:
   That is a technical solution related to how SQLAlchemy constructs table identifiers. The assumption is to have `database` -> `schema` -> `table_name` hierarchy with first two optional.
   I've added a short explanation how above solution works.



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


[GitHub] [airflow] mobuchowski commented on a diff in pull request #32910: openlineage, trino: add OpenLineage support for Trino.

Posted by "mobuchowski (via GitHub)" <gi...@apache.org>.
mobuchowski commented on code in PR #32910:
URL: https://github.com/apache/airflow/pull/32910#discussion_r1304074061


##########
airflow/providers/openlineage/utils/sql.py:
##########
@@ -155,11 +155,17 @@ def create_information_schema_query(
     metadata = MetaData(sqlalchemy_engine)
     select_statements = []
     for db, schema_mapping in tables_hierarchy.items():
-        schema, table_name = information_schema_table_name.split(".")
         if db:
-            schema = f"{db}.{schema}"
+            schema = db

Review Comment:
   👍 



##########
airflow/providers/openlineage/utils/sql.py:
##########
@@ -155,11 +155,17 @@ def create_information_schema_query(
     metadata = MetaData(sqlalchemy_engine)
     select_statements = []
     for db, schema_mapping in tables_hierarchy.items():
-        schema, table_name = information_schema_table_name.split(".")
         if db:
-            schema = f"{db}.{schema}"
+            schema = db

Review Comment:
   👍 



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