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 6 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,61 @@

@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: int
outgoing: int
hsheth2 marked this conversation as resolved.
Show resolved Hide resolved
source: str = "mssql"


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

@property
def get_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 get_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 get_input_datajobs(self) -> List[str]:
anshbansal 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 +112,7 @@ class MSSQLProceduresContainer:
env: str
source: str = "mssql"
type: str = "JOB"
schema: str = ""

@property
def formatted_name(self) -> str:
Expand Down Expand Up @@ -183,15 +231,15 @@ def valued_properties(self) -> Dict[str, str]:
return self.job_properties

@property
def as_datajob_input_output_aspect(self) -> DataJobInputOutputClass:
def get_datajob_input_output_aspect(self) -> DataJobInputOutputClass:
return DataJobInputOutputClass(
inputDatasets=sorted(self.incoming),
outputDatasets=sorted(self.outgoing),
inputDatajobs=sorted(self.input_jobs),
)

@property
def as_datajob_info_aspect(self) -> DataJobInfoClass:
def get_datajob_info_aspect(self) -> DataJobInfoClass:
return DataJobInfoClass(
name=self.entity.full_name,
type=self.entity.full_type,
Expand Down Expand Up @@ -229,7 +277,7 @@ def urn(self) -> str:
)

@property
def as_dataflow_info_aspect(self) -> DataFlowInfoClass:
def get_dataflow_info_aspect(self) -> DataFlowInfoClass:
return DataFlowInfoClass(
name=self.entity.formatted_name,
customProperties=self.flow_properties,
Expand Down
Loading
Loading