Skip to content
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

Feature/update logic mssql lineage #10959

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from dataclasses import dataclass, field
from typing import Dict, List, Optional, Union

from datahub.emitter.mce_builder import make_data_flow_urn, make_data_job_urn
from datahub.emitter.mce_builder import (
make_data_flow_urn,
make_data_job_urn,
make_dataset_urn_with_platform_instance,
)
from datahub.metadata.schema_classes import (
DataFlowInfoClass,
DataJobInfoClass,
Expand All @@ -11,18 +15,65 @@

@dataclass
class ProcedureDependency:
flow_id: str
env: str
server: Optional[str]
db: str
schema: str
name: str
type: str
env: str
server: Optional[str]
incoming: Union[str, int]
outgoing: Union[str, int]
source: str = "mssql"

def __post_init__(self):
self.incoming = int(self.incoming)
self.outgoing = int(self.outgoing)
hsheth2 marked this conversation as resolved.
Show resolved Hide resolved


@dataclass
class ProcedureLineageStream:
dependencies: List[ProcedureDependency]
dependencies: List[ProcedureDependency] = field(default_factory=list)

@property
def as_input_datasets(self) -> List[str]:
return [
make_dataset_urn_with_platform_instance(
platform=dep.source,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dep.source is always mssql right?

Copy link
Contributor Author

@sleeperdeep sleeperdeep Aug 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. Because procedure dependencies are extraqcting by _populate_stored_procedures_dependencies method, which query is built around:

name=".".join([dep.db, dep.schema, dep.name]),
platform_instance=dep.server,
env=dep.env,
)
for dep in self.dependencies
if dep.type in ("U ", "V ") and dep.incoming
]

@property
def as_output_datasets(self) -> List[str]:
return [
make_dataset_urn_with_platform_instance(
platform=dep.source,
name=".".join([dep.db, dep.schema, dep.name]),
platform_instance=dep.server,
env=dep.env,
)
for dep in self.dependencies
if dep.type in ("U ", "V ") and dep.outgoing
]

@property
def as_input_datajobs(self) -> List[str]:
hsheth2 marked this conversation as resolved.
Show resolved Hide resolved
return [
make_data_job_urn(
orchestrator=dep.source,
flow_id=dep.flow_id,
job_id=dep.name,
cluster=dep.env,
platform_instance=dep.server,
)
for dep in self.dependencies
if dep.type in ("P ",) and dep.incoming
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a comment in the code explaining what "P " is for

]

@property
def as_property(self) -> Dict[str, str]:
Expand Down Expand Up @@ -65,6 +116,7 @@ class MSSQLProceduresContainer:
env: str
source: str = "mssql"
type: str = "JOB"
schema: str = ""

@property
def formatted_name(self) -> str:
Expand Down
Loading
Loading