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

snowflake.snowpark.files.SnowflakeFile.open

classmethod SnowflakeFile.open(file_location: str, mode: str = 'r', is_owner_file: bool = False, *, require_scoped_url: bool = True) SnowflakeFile[source]

Returns a SnowflakeFile. In UDF and Stored Procedures, the object works like a Python IOBase object and as a wrapper for an IO stream of remote files. The IO Stream is to support the file operations defined in this class.

All files are accessed in the context of the UDF owner (with the exception of caller’s rights stored procedures which use the caller’s context). UDF callers should use scoped URLs to allow the UDF to access their files. By accepting only scoped URLs the UDF owner can ensure the UDF caller had access to the provided file. Removing the requirement that the URL is a scoped URL (require_scoped_url=false) allows the caller to provide URLs that may be only accessible by the UDF owner.

is_owner_file is marked for deprecation. For Snowflake release 7.8 and onwards please use require_scoped_url instead.

Parameters:
  • file_location – scoped URL, file URL, or string path for files located in a stage

  • mode – A string used to mark the type of an IO stream.

  • is_owner_file – (Deprecated) A boolean value, if True, the API is intended to access owner’s files and all URI/URL are allowed. If False, the API is intended to access files passed into the function by the caller and only scoped URL is allowed.

  • require_scoped_url – A boolean value, if True, file_location must be a scoped URL. A scoped URL ensures that the caller cannot access the UDF owners files that the caller does not have access to.