snowflake-cli
snowflake-cli copied to clipboard
SNOW-1369861: Ability to specify source_path as a pattern rather than limit to a directory
Description
Currently the following statement errors out
snow --config-file config.toml stage copy -c myconnection --overwrite ./*.py @FQ_Stage_Name
Therefore, the workaround based on documentation was to move the files to a temp directory and then copy to stage
mkdir temp
mv ./*.py ./temp
mv ./img/* ./temp
mv ./requirements.txt ./temp
snow --config-file config.toml stage copy -c myconnection --overwrite ./temp @db.schema.stage_name
Context
I would like to have this command work in snowflake cli
snow --config-file config.toml stage copy -c myconnection --overwrite ./*.py @FQ_Stage_Name
Hello, it should work if you use quotes around your pattern. We'll improve the docs to mention that.
Please the see examples for using patterns in a current working directory and in a subdirectory:
(.venv) ➜ 026 snow --version
Snowflake CLI version: 2.2.0
(.venv) ➜ 026 vim a1.txt
(.venv) ➜ 026 vim a2.txt
(.venv) ➜ 026 snow stage copy --overwrite "./*.txt" @TEST_STAGE_1
put file:///<my-path>/026/*.txt @TEST_STAGE_1 auto_compress=false parallel=4 overwrite=True
+------------------------------------------------------------------------------------------------------------+
| source | target | source_size | target_size | source_compression | target_compression | status | message |
|--------+--------+-------------+-------------+--------------------+--------------------+----------+---------|
| a1.txt | a1.txt | 3 | 16 | NONE | NONE | UPLOADED | |
| a2.txt | a2.txt | 3 | 16 | NONE | NONE | UPLOADED | |
+------------------------------------------------------------------------------------------------------------+
(.venv) ➜ 026 mkdir subdir
(.venv) ➜ 026 vim subdir/b1.txt
(.venv) ➜ 026 vim subdir/b2.txt
(.venv) ➜ 026 snow stage copy --overwrite "subdir/*.txt" @TEST_STAGE_1
put file:///<my-path>/026/subdir/*.txt @TEST_STAGE_1 auto_compress=false parallel=4 overwrite=True
+------------------------------------------------------------------------------------------------------------+
| source | target | source_size | target_size | source_compression | target_compression | status | message |
|--------+--------+-------------+-------------+--------------------+--------------------+----------+---------|
| b1.txt | b1.txt | 3 | 16 | NONE | NONE | UPLOADED | |
| b2.txt | b2.txt | 3 | 16 | NONE | NONE | UPLOADED | |
+------------------------------------------------------------------------------------------------------------+