Skip to content

Commit

Permalink
Merge pull request #608 from zen-xu/pythonic-set-default-env
Browse files Browse the repository at this point in the history
refactor: A more Pythonic way to set environment variables.
  • Loading branch information
wangxiaoying authored Apr 17, 2024
2 parents 214c45e + de47267 commit db7e121
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions connectorx-python/connectorx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,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: str | None = None):
Expand Down Expand Up @@ -202,7 +201,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 @@ -231,7 +229,6 @@ def read_sql(
return df

if isinstance(query, str):

query = remove_ending_semicolon(query)

if partition_on is None:
Expand Down Expand Up @@ -382,8 +379,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

0 comments on commit db7e121

Please sign in to comment.