Skip to content

Commit

Permalink
fix code according comment iteration 2
Browse files Browse the repository at this point in the history
  • Loading branch information
sleeperdeep committed Aug 2, 2024
1 parent 6dd44dd commit b9f357b
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
import re
import urllib.parse
from collections import defaultdict
from typing import Any, Dict, Iterable, List, Optional, Tuple, Union

import pydantic
Expand Down Expand Up @@ -172,8 +173,10 @@ def __init__(self, config: SQLServerConfig, ctx: PipelineContext):
self.current_database = None
self.table_descriptions: Dict[str, str] = {}
self.column_descriptions: Dict[str, str] = {}
self.full_lineage: Dict[str, List[Dict[str, str]]] = {}
self.procedures_dependencies: Dict[str, List[Dict[str, str]]] = {}
self.full_lineage: Dict[str, List[Dict[str, str]]] = defaultdict(list)
self.procedures_dependencies: Dict[str, List[Dict[str, str]]] = defaultdict(
list
)
if self.config.include_descriptions:
for inspector in self.get_inspectors():
db_name = self.get_db_name(inspector)
Expand Down Expand Up @@ -294,7 +297,6 @@ def get_ucs(self, inspector: Inspector, key: str) -> List[UpstreamClass]:
return result

def _populate_stored_procedures_dependencies(self, conn: Connection) -> None:
_procedures_dependencies: Dict[str, List[Dict[str, str]]] = {}

trans = conn.begin()

Expand Down Expand Up @@ -555,7 +557,7 @@ def _populate_stored_procedures_dependencies(self, conn: Connection) -> None:
if row:
_key = f"{row['current_db'].lower() if db_force_converting else row['current_db']}.{row['procedure_schema']}.{row['procedure_name']}"

_procedures_dependencies.setdefault(_key, []).append(
self.procedures_dependencies[_key].append(
{
"referenced_database_name": row[
"referenced_database_name"
Expand All @@ -573,8 +575,6 @@ def _populate_stored_procedures_dependencies(self, conn: Connection) -> None:

trans.commit()

self.procedures_dependencies = _procedures_dependencies

def _populate_object_links(self, conn: Connection, db_name: str) -> None:
# see https://learn.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-sql-expression-dependencies-transact-sql
_links = conn.execute(
Expand All @@ -599,7 +599,7 @@ def _populate_object_links(self, conn: Connection, db_name: str) -> None:
# {"U ": "USER_TABLE", "V ": "VIEW", "P ": "SQL_STORED_PROCEDURE"}
for row in _links:
_key = f"{db_name}.{row['dst_schema_name']}.{row['dst_object_name']}"
self.full_lineage.setdefault(_key, []).append(
self.full_lineage[_key].append(
{
"schema": row["src_schema_name"] or row["dst_schema_name"],
"name": row["src_object_name"],
Expand Down

0 comments on commit b9f357b

Please sign in to comment.