-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(ingest/bigquery): Standardize audit log parsing and make TopKDict a DefaultDict #7738
refactor(ingest/bigquery): Standardize audit log parsing and make TopKDict a DefaultDict #7738
Conversation
…t creation; standardize audit log parsing; make TopKDict a DefaultDict
lineage_extractor: BigqueryLineageExtractor = BigqueryLineageExtractor( | ||
config=self.config, report=self.report | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No clue why we were doing this... was in this code from the very first bigquery lineage PR. The only instance variables are self.config
and self.report
, which are passed thru anyway, so I think this should be safe to remove
raise e | ||
|
||
def compute_bigquery_lineage_via_catalog_lineage_api( | ||
def lineage_via_catalog_lineage_api( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed compute_bigquery_lineage_via_catalog_lineage_api
to be a bit more concise
def _get_bigquery_log_entries( | ||
self, client: GCPLoggingClient, limit: Optional[int] = None | ||
) -> Union[Iterable[AuditLogEntry], Iterable[BigQueryAuditMetadata]]: | ||
) -> Union[Iterable[AuditLogEntry]]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think this is a more accurate typing. Technically it doesn't matter because both AuditLogEntry
and BigQueryAuditMetadata
are Any
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
incredible
logger.warning( | ||
f"Unable to parse log missing {missing_entry}, missing v2 {missing_entry_v2} for {entry}", | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seemed more fitting as a log warning, rather than in the report as an error
self.error( | ||
logger, | ||
"lineage", | ||
f"{project_id}: {e}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to replace the self.error
calls in the deleted compute_bigquery_lineage_via_gcp_logging
and compute_bigquery_lineage_via_audit_metadata
. Since this is catching unexpected errors and has a relatively clean message, I think this is valid to put in the report.
@@ -492,7 +487,7 @@ def _extract_operational_meta( | |||
else: | |||
return None | |||
|
|||
def _create_operation_aspect_work_unit( | |||
def _create_operation_workunit( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another rename
Bit again by not separating out some changes into a smaller PR. Takes changes from #7663 and extends them for lineage.py, i.e.:
get_sanitized_table_ref
calls to ReadEvent / QueryEvent creationget_sanitized_table_ref
callsAlso. makes
TopKDict
inherit fromDefaultDict
and cleans up calls around that.Checklist