You are viewing documentation about an older version (1.2.0). View latest version

snowflake.snowpark.FileOperation.get_stream

FileOperation.get_stream(stage_location: str, *, parallel: int = 10, decompress: bool = False, statement_params: Dict[str, str] | None = None) IO[bytes][source]

Downloads the specified files from a path in a stage and expose it through a stream.

Parameters:
  • stage_location – The full stage path with prefix and file name, from which you want to download the file.

  • parallel – Specifies the number of threads to use for downloading the files. The granularity unit for downloading is one file. Increasing the number of threads might improve performance when downloading large files. Supported values: Any integer value from 1 (no parallelism) to 99 (use 99 threads for downloading files). Defaults to 10.

  • statement_params – Dictionary of statement level parameters to be set while executing this action. Defaults to None.

  • decompress – Specifies whether to use gzip to decompress file after download. Defaults to False.

Examples

>>> # Create a temp stage.
>>> _ = session.sql("create or replace temp stage mystage").collect()
>>> # Upload a file to a stage.
>>> _ = session.file.put("tests/resources/testCSV.csv", "@mystage/prefix1")
>>> # Download one file from a stage.
>>> fd = session.file.get_stream("@myStage/prefix1/testCSV.csv.gz", decompress=True)
>>> assert fd.read(5) == b"1,one"
>>> fd.close()
Copy
Returns:

An BytesIO object which points to the downloaded file.