Closed sfc-gh-psanford closed 4 months ago
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅
Hi, Can you also post your test code here?
Here's a repro script:
import tempfile
import snowflake.connector
import os
home_path = os.getenv("HOME")
data_path = os.path.join(home_path, "<path to repo>/ExecPlatform/Database/data/orders_10*.csv")
print(f"Using data path {data_path}")
conn = snowflake.connector.connect(<local regression test instance connection details>)
try:
conn.cursor().execute("create database local_transfer_test")
conn.cursor().execute("use local_transfer_test")
conn.cursor().execute("use schema public")
conn.cursor().execute("create stage local_stage")
conn.cursor().execute(f"PUT file://{data_path} @local_stage/subdir")
res = conn.cursor().execute("ls @local_stage").get_result_batches()
for batch in res:
for row in batch.create_iter():
print(row)
tmp_path = tempfile.mkdtemp()
print(f"Tmp path: {tmp_path}")
conn.cursor().execute(f"GET @local_stage/subdir file://{tmp_path}")
finally:
conn.cursor().execute("drop database local_transfer_test")
I have read the CLA Document and I hereby sign the CLA
Description
When running
GET
queries in a local deployment, if a prefix path is provided in theGET
query, the connector doesn't correctly generate the source file location. See SNOW-1208964 for a detailed example.Testing
Please answer these questions before submitting your pull requests. Thanks!
What GitHub issue is this PR addressing? Make sure that there is an accompanying issue to your PR.
Fixes SNOW-1208964
Fill out the following pre-review checklist:
Please describe how your code solves the related issue.
When creating a destination filepath for
PUT
, the connector uses only the basename of the file. This works even with subdirectories because in thePUT
case,stage_info["location"]
contains the subdirectory path.For
GET
, the connector is using the same logic to construct the source filepath, but the prefix is not included instage_info["location"]
. This PR instead constructs the source filename based onreal_src_file_name
in theGET
case.I also changed
shutil.copyfile
toshutil.move
infinish_download
- this was leaving<filename>.part
files in the destination directory.