From 380eb48191494bd257f22a4d7979ff043b58c525 Mon Sep 17 00:00:00 2001 From: sfc-gh-sfan Date: Thu, 23 Mar 2023 16:16:59 -0700 Subject: [PATCH 1/3] SNOW-761256 Fix finish_download in gcs_storage_client Description After super().finish_download(), self.intermediate_dst_path has either been deleted or removed. We should use the dst file name instead. Testing Existing test. I'm curious to learn how to test as well --- src/snowflake/connector/gcs_storage_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/snowflake/connector/gcs_storage_client.py b/src/snowflake/connector/gcs_storage_client.py index 5f1aef002..4e14c9b0a 100644 --- a/src/snowflake/connector/gcs_storage_client.py +++ b/src/snowflake/connector/gcs_storage_client.py @@ -217,7 +217,7 @@ def finish_download(self) -> None: # Sadly, we can only determine the src file size after we've # downloaded it, unlike the other cloud providers where the # metadata can be read beforehand. - self.meta.src_file_size = os.path.getsize(self.intermediate_dst_path) + self.meta.src_file_size = os.path.getsize(self.full_dst_file_name) def _update_presigned_url(self) -> None: """Updates the file metas with presigned urls if any. From 346f686835f4cb8335f15465923b70ab84af564c Mon Sep 17 00:00:00 2001 From: sfc-gh-sfan Date: Thu, 23 Mar 2023 16:28:24 -0700 Subject: [PATCH 2/3] Add test --- test/integ/test_put_get.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/integ/test_put_get.py b/test/integ/test_put_get.py index e4a5e08e5..4e1befd28 100644 --- a/test/integ/test_put_get.py +++ b/test/integ/test_put_get.py @@ -6,6 +6,7 @@ from __future__ import annotations import filecmp +import logging import os import pathlib from getpass import getuser @@ -675,7 +676,7 @@ def test_get_empty_file(tmp_path, conn_cnx): @pytest.mark.skipolddriver -def test_get_file_permission(tmp_path, conn_cnx): +def test_get_file_permission(tmp_path, conn_cnx, caplog): test_file = tmp_path / "data.csv" test_file.write_text("1,2,3\n") stage_name = random_string(5, "test_get_empty_file_") @@ -687,7 +688,10 @@ def test_get_file_permission(tmp_path, conn_cnx): f"PUT 'file://{filename_in_put}' @{stage_name}", ) - cur.execute(f"GET @{stage_name}/data.csv file://{tmp_path}") + with caplog.at_level(logging.ERROR): + cur.execute(f"GET @{stage_name}/data.csv file://{tmp_path}") + assert "FileNotFoundError" not in caplog.text + # get the default mask, usually it is 0o022 default_mask = os.umask(0) os.umask(default_mask) From 27a00f2293b501a3a6b1b485d19a64923b506bed Mon Sep 17 00:00:00 2001 From: sfc-gh-sfan Date: Thu, 23 Mar 2023 16:31:07 -0700 Subject: [PATCH 3/3] add change log --- DESCRIPTION.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/DESCRIPTION.md b/DESCRIPTION.md index a1981ef80..b817d8529 100644 --- a/DESCRIPTION.md +++ b/DESCRIPTION.md @@ -8,6 +8,10 @@ Source code is also available at: https://github.com/snowflakedb/snowflake-conne # Release Notes +- v3.0.3(TBD) + + - Fixed a bug that prints error in logs for GET command on GCS + - v3.0.2(March 23, 2023) - Fixed a memory leak in the logging module of the Cython extension.