File tree 2 files changed +28
-4
lines changed
2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change 17
17
import warnings
18
18
from pathlib import Path
19
19
from typing import TYPE_CHECKING , Any
20
+ from urllib .request import urlretrieve
20
21
21
22
import pyarrow as pa
22
23
import pyarrow_hotfix # noqa: F401
@@ -777,10 +778,17 @@ def read_csv(
777
778
)
778
779
con .exec_driver_sql (create_infer_fmt )
779
780
780
- # copy the local file to the stage
781
- con .exec_driver_sql (
782
- f"PUT 'file://{ Path (path ).absolute ()} ' @{ stage } PARALLEL = { threads :d} "
783
- )
781
+ if path .startswith ("https://" ):
782
+ with tempfile .NamedTemporaryFile () as tmp :
783
+ urlretrieve (path , filename = tmp .name )
784
+ tmp .flush ()
785
+ con .exec_driver_sql (
786
+ f"PUT 'file://{ tmp .name } ' @{ stage } PARALLEL = { threads :d} AUTO_COMPRESS = TRUE"
787
+ )
788
+ else :
789
+ con .exec_driver_sql (
790
+ f"PUT 'file://{ Path (path ).absolute ()} ' @{ stage } PARALLEL = { threads :d} AUTO_COMPRESS = TRUE"
791
+ )
784
792
785
793
# handle setting up the schema in python because snowflake is
786
794
# broken for csv globs: it cannot parse the result of the following
Original file line number Diff line number Diff line change @@ -197,6 +197,22 @@ def test_read_csv_options(con, tmp_path):
197
197
assert t .schema () == ibis .schema (dict (a = "int64" , b = "int64" ))
198
198
199
199
200
+ def test_read_csv_https (con ):
201
+ t = con .read_csv (
202
+ "https://storage.googleapis.com/ibis-tutorial-data/wowah_data/locations.csv" ,
203
+ field_optionally_enclosed_by = '"' ,
204
+ )
205
+ assert t .schema () == ibis .schema (
206
+ {
207
+ "Map_ID" : "int64" ,
208
+ "Location_Type" : "string" ,
209
+ "Location_Name" : "string" ,
210
+ "Game_Version" : "string" ,
211
+ }
212
+ )
213
+ assert t .count ().execute () == 151
214
+
215
+
200
216
@pytest .fixture (scope = "module" )
201
217
def json_data ():
202
218
return [
You can’t perform that action at this time.
0 commit comments