uranusjr commented on code in PR #31398:
URL: https://github.com/apache/airflow/pull/31398#discussion_r1242240129
##########
airflow/providers/common/sql/hooks/sql.py:
##########
@@ -515,3 +516,55 @@ def test_connection(self):
message = str(e)
return status, message
+
+ def get_database_info_for_openlineage(self, connection):
+ """
+ Should return database specific information needed
+ to generate and parse lineage metadata.
+ This includes information helpful for constructing information schema
query
+ and creating correct namespace.
+
+ :param connection: Airflow connection to reduce calls of
`get_connection` method
+ :return: A
:class:`airflow.providers.openlineage.sqlparser.DatabaseInfo` instance.
+ """
+
+ def get_database_dialect(self, connection) -> str:
+ """Method used for SQL parsing.
+
+ For a list of supported dialects check:
https://openlineage.io/docs/development/sql#sql-dialects
+ """
+ return "generic"
+
+ def get_default_schema(self):
+ """
+ Returns default schema specific to database.
+
+ .. seealso::
+ - :class:`airflow.providers.openlineage.sqlparser.SQLParser`
+ """
+ return self.__schema or "public"
+
+ def get_database_specific_lineage(self, task_instance):
+ """
+ Returns additional database specific lineage, e.g.
+ query execution information.
+ This method is called only on completion of the task.
+
+ :param task_instance: this may be used to retrieve additional
information
+ that is collected during runtime of the task
+ """
+
+ @staticmethod
+ def get_openlineage_authority_part(connection) -> str:
+ """
+ This method serves as common method for several hooks to get authority
part from Airflow Connection.
+
+ The authority represents the hostname and port of the connection
+ and conforms OpenLineage naming convention for a number of databases
(e.g. MySQL, Postgres, Trino).
+ """
+ if connection.port and connection.host:
+ authority = f"{connection.host}:{connection.port}"
Review Comment:
Is this block necessary? I thought the `get_uri` approach would produce the
same result for this case.
--
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]