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

refactor: A more Pythonic way to set environment variables. #608

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Changes from all 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
17 changes: 7 additions & 10 deletions connectorx-python/connectorx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@
not os.path.basename(os.path.abspath(os.path.join(dir_path, "..")))
== "connectorx-python"
):
if "J4RS_BASE_PATH" not in os.environ:
os.environ["J4RS_BASE_PATH"] = os.path.join(dir_path, "dependencies")
if "CX_REWRITER_PATH" not in os.environ:
os.environ["CX_REWRITER_PATH"] = os.path.join(
dir_path, "dependencies/federated-rewriter.jar"
)
os.environ.setdefault("J4RS_BASE_PATH", os.path.join(dir_path, "dependencies"))

os.environ.setdefault(
"CX_REWRITER_PATH", os.path.join(dir_path, "dependencies/federated-rewriter.jar")
)


def rewrite_conn(conn: str, protocol: Optional[str] = None):
Expand Down Expand Up @@ -208,7 +207,6 @@ def read_sql(
query = query[0]
query = remove_ending_semicolon(query)


if isinstance(conn, dict):
assert partition_on is None and isinstance(
query, str
Expand Down Expand Up @@ -237,7 +235,6 @@ def read_sql(
return df

if isinstance(query, str):

query = remove_ending_semicolon(query)

if partition_on is None:
Expand Down Expand Up @@ -388,8 +385,8 @@ def reconstruct_pandas(df_infos: Dict[str, Any]):


def remove_ending_semicolon(query: str) -> str:
if query[-1] == ';':
query= list(query)
if query[-1] == ";":
query = list(query)
query.pop(-1)
query = "".join(query)
return query
Loading