snowflake.snowpark.PutResult

class snowflake.snowpark.PutResult(source: str, target: str, source_size: int, target_size: int, source_compression: str, target_compression: str, status: str, message: str)[source]

Bases: NamedTuple

Represents the results of uploading a local file to a stage location.

FileOperation.put() returns a list of these objects. Inspect each object’s source, target, status, and message attributes to identify the file and its upload outcome. SKIPPED means the file wasn’t uploaded; it doesn’t mean a new upload succeeded.

This example requires an existing internal stage named example_stage and a session authorized to upload to it. It creates only a local text fixture; use a stage intended for testing. File names and sizes in the returned objects depend on the input and compression options.

Example:

>>> from pathlib import Path
>>> from tempfile import TemporaryDirectory
>>> with TemporaryDirectory() as directory:  
...     path = Path(directory) / "message.txt"
...     _ = path.write_text("hello", encoding="utf-8")
...     results = session.file.put(str(path), "@example_stage", auto_compress=False)
...     for result in results:
...         print(result.source, result.target, result.status, result.message)

Methods

Attributes

message

The detailed message of the upload status.

source

The source file path.

source_compression

The source file compression format.

source_size

The size in bytes of the source file.

status

Status indicating whether the file was uploaded to the stage.

target

The file path in the stage where the source file is uploaded.

target_compression

The target file compression format.

target_size

The size in bytes of the target file.