Skip to content

Commit

Permalink
merge lineagex
Browse files Browse the repository at this point in the history
  • Loading branch information
zshandy authored and dovahcrow committed Aug 3, 2023
1 parent 55c3932 commit ddefeab
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions dataprep/integrate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .lx import lineagex
40 changes: 40 additions & 0 deletions dataprep/integrate/lx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""
This module contains the method of lineagex.
It is a wrapper on lineagex.lineagex function.
"""
from typing import Optional, Union, List

try:
import lineagex as lx

_WITH_LX = True
except ImportError:
_WITH_LX = False


def lineagex(
sql: Optional[Union[List, str]] = None,
target_schema: Optional[str] = "",
conn_string: Optional[str] = None,
search_path_schema: Optional[str] = "",
) -> dict:
"""
Produce the lineage information.
Please check out https://github.com/sfu-db/lineagex for more details.
:param sql: The input of the SQL files, it can be a path to a file, a path to a folder containing SQL files, a list of SQLs or a list of view names and/or schemas
:param target_schema: The schema where the SQL files would be created, defaults to public, or the first schema in the search_path_schema if provided
:param conn_string: The postgres connection string in the format postgresql://username:password@server:port/database, defaults to None
:param search_path_schema: The SET search_path TO ... schemas, defaults to public or the target_schema if provided
:return:
"""

if _WITH_LX:
output_dict = lx.lineagex(
sql=sql,
target_schema=target_schema,
conn_string=conn_string,
search_path_schema=search_path_schema,
).output_dict
return output_dict
else:
raise ImportError("lineagex is not installed." "Please run pip install lineagex")

0 comments on commit ddefeab

Please sign in to comment.