Skip to content

Commit ec41d4c

Browse files
authored
fix(snowflake): use as_posix instead of as_uri to avoid escaping special characters (#10792)
1 parent fa4d958 commit ec41d4c

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

ibis/backends/clickhouse/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def do_connect(
149149
Examples
150150
--------
151151
>>> import ibis
152-
>>> client = ibis.clickhouse.connect()
152+
>>> client = ibis.clickhouse.connect(user="ibis")
153153
>>> client
154154
<ibis.backends.clickhouse.Backend object at 0x...>
155155
"""

ibis/backends/snowflake/__init__.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,6 @@
137137
}
138138

139139

140-
def as_uri(path: str | Path) -> str:
141-
"""Convert a path to a file URI."""
142-
return Path(path).absolute().as_uri()
143-
144-
145140
class Backend(SQLBackend, CanCreateCatalog, CanCreateDatabase):
146141
name = "snowflake"
147142
compiler = sc.snowflake.compiler
@@ -926,10 +921,12 @@ def read_csv(
926921
urlretrieve(path, filename=tmpname) # noqa: S310
927922
tmp.flush()
928923
cur.execute(
929-
f"PUT '{as_uri(tmpname)}' @{stage} PARALLEL = {threads:d}"
924+
f"PUT 'file://{Path(tmpname).absolute().as_posix()}' @{stage} PARALLEL = {threads:d}"
930925
)
931926
else:
932-
cur.execute(f"PUT '{as_uri(path)}' @{stage} PARALLEL = {threads:d}")
927+
cur.execute(
928+
f"PUT 'file://{Path(path).absolute().as_posix()}' @{stage} PARALLEL = {threads:d}"
929+
)
933930

934931
# handle setting up the schema in python because snowflake is
935932
# broken for csv globs: it cannot parse the result of the following
@@ -1055,7 +1052,7 @@ def read_json(
10551052
)
10561053
with self._safe_raw_sql(";\n".join(stmts)) as cur:
10571054
cur.execute(
1058-
f"PUT 'file://{Path(path).absolute()}' @{stage} PARALLEL = {threads:d}"
1055+
f"PUT 'file://{Path(path).absolute().as_posix()}' @{stage} PARALLEL = {threads:d}"
10591056
)
10601057
cur.execute(
10611058
";\n".join(
@@ -1104,7 +1101,7 @@ def read_parquet(
11041101

11051102
from ibis.formats.pyarrow import PyArrowSchema
11061103

1107-
abspath = Path(path).absolute()
1104+
abspath = Path(path).absolute().as_posix()
11081105
schema = PyArrowSchema.to_ibis(
11091106
ds.dataset(glob.glob(str(abspath)), format="parquet").schema
11101107
)

0 commit comments

Comments
 (0)