-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for
snow://
stage paths (#1346)
* Add support for snow:// stage prefix * Fix file name extraction from single quoted paths * Apply snow:// support to put* path * Update CHANGELOG * Move path splitting to helper method * Add unit tests for updated normalize_path and split_path utils
- Loading branch information
1 parent
96da8e9
commit 78c11ac
Showing
4 changed files
with
87 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# | ||
# Copyright (c) 2012-2023 Snowflake Computing Inc. All rights reserved. | ||
# | ||
|
||
import pytest | ||
|
||
from snowflake.snowpark._internal import utils | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"path, expected_dir, expected_file", | ||
[ | ||
("stage/", "stage", ""), | ||
("stage/file.txt", "stage", "file.txt"), | ||
("dir/subdir/file.txt", "dir/subdir", "file.txt"), | ||
("@stage/dir/subdir/file.txt", "@stage/dir/subdir", "file.txt"), | ||
("'@stage/dir/subdir/file.txt'", "@stage/dir/subdir", "file.txt"), | ||
( | ||
"snow://domain/test_entity/versions/test_version/file.txt", | ||
"snow://domain/test_entity/versions/test_version", | ||
"file.txt", | ||
), | ||
( | ||
"'snow://domain/test_entity/versions/test_version/file.txt'", | ||
"snow://domain/test_entity/versions/test_version", | ||
"file.txt", | ||
), | ||
], | ||
) | ||
def test_split_path(path: str, expected_dir: str, expected_file: str) -> None: | ||
dir, file = utils.split_path(path) | ||
assert expected_dir == dir | ||
assert expected_file == file | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"path, is_local, expected", | ||
[ | ||
("dir/file.txt", True, "'file://dir/file.txt'"), | ||
("dir/subdir/file.txt", True, "'file://dir/subdir/file.txt'"), | ||
("'dir/subdir/file.txt'", True, "'dir/subdir/file.txt'"), | ||
("file://dir/subdir/file.txt", True, "'file://dir/subdir/file.txt'"), | ||
("stage/", False, "'@stage/'"), | ||
("stage/file.txt", False, "'@stage/file.txt'"), | ||
("'stage/file.txt'", False, "'stage/file.txt'"), | ||
( | ||
"stage/'embedded_quote'/file.txt", | ||
False, | ||
"'@stage/\\'embedded_quote\\'/file.txt'", | ||
), | ||
("@stage/dir/subdir/file.txt", False, "'@stage/dir/subdir/file.txt'"), | ||
("'@stage/dir/subdir/file.txt'", False, "'@stage/dir/subdir/file.txt'"), | ||
( | ||
"snow://domain/test_entity/versions/test_version/file.txt", | ||
False, | ||
"'snow://domain/test_entity/versions/test_version/file.txt'", | ||
), | ||
( | ||
"'snow://domain/test_entity/versions/test_version/file.txt'", | ||
False, | ||
"'snow://domain/test_entity/versions/test_version/file.txt'", | ||
), | ||
], | ||
) | ||
def test_normalize_path(path: str, is_local: bool, expected: str) -> None: | ||
actual = utils.normalize_path(path, is_local) | ||
assert expected == actual |