We are trying to load data from an S3 bucket into Snowflake using COPY INTO. Works perfectly.. But data in subfolders are also being copied, and this shoud not not happen.
Following hardcoded pattern REGEX works perfectly
copy into TARGETTABLE
from @SOURCESTAGE
pattern='^(?!.*subfolder/).*$'
But we don't want to hardcode the foldername. When I just keep the '/' it doesn't work anymore.. ( same happens when I escape the slash \/ )
copy into TARGETTABLE
from @SOURCESTAGE
pattern='^(?!.*/).*$'
Does anybody knows which REGEX to use to skip any subfolder in the COP INTO in a dynamic way? (no hardcoding of folder name )
@test_stage/folder_include
@test_stage/folder_include/file_that_has_to_be_loaded.csv
@test_stage/folder_include/folder_exclude/file_that_cannot_be_loaded.csv
So only files within folder_include can be picked up by the copy into statement. Everything in a lower level needs to be skipped. Most importantly: without hardcoding on foldername. Any folder within folder_include has to be ignored.
Thanks!