pawelgrochowicz commented on code in PR #56348:
URL: https://github.com/apache/airflow/pull/56348#discussion_r2401411693
##########
providers/google/src/airflow/providers/google/cloud/hooks/spanner.py:
##########
@@ -427,3 +430,40 @@ def _execute_sql_in_transaction(transaction: Transaction,
queries: list[str]) ->
rc = transaction.execute_update(sql)
counts[sql] = rc
return counts
+
+ def _get_openlineage_authority_part(self, connection):
+ """Build Spanner-specific authority part for OpenLineage. Returns
{project}/{instance}."""
+ extras = connection.extra_dejson
+ project_id = extras.get("project_id")
+ instance_id = extras.get("instance_id")
+
+ if not project_id or not instance_id:
+ return None
+
+ return f"{project_id}/{instance_id}"
+
+ def get_openlineage_database_dialect(self, connection: Connection) -> str:
+ """Return database dialect for OpenLineage."""
+ return "spanner"
+
+ def get_openlineage_database_info(self, connection: Connection) ->
DatabaseInfo:
+ """Return Spanner specific information for OpenLineage."""
+ extras = connection.extra_dejson
+ database_id = extras.get("database_id")
+
+ return DatabaseInfo(
+ scheme=self.get_openlineage_database_dialect(connection),
+ authority=self._get_openlineage_authority_part(connection),
+ database=database_id,
+ information_schema_columns=[
+ "table_schema",
+ "table_name",
+ "column_name",
+ "ordinal_position",
+ "spanner_type",
+ ],
+ )
+
+ def get_openlineage_default_schema(self) -> str | None:
+ """Spanner expose 'public' or '' schema depending on dialect(Postgres
vs GoogleSQL)."""
+ return None
Review Comment:
To follow the same approach as in SQLAlchemy for the Spanner -
https://github.com/googleapis/python-spanner-sqlalchemy.
--
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]