Class SnowflakeFile


  • public class SnowflakeFile
    extends Object
    Custom Snowflake class that provides users with additional information on top of the core capability of reading Snowflake files.
    Since:
    1.3.0
    • Constructor Detail

      • SnowflakeFile

        public SnowflakeFile()
    • Method Detail

      • newInstance

        public static SnowflakeFile newInstance​(String scopedUrl)
        Create a new instance of SnowflakeFile. Calls into our C++ layer to construct it.
        Parameters:
        scopedUrl - can be scoped URL. Stage file references should use newInstanceFromOwnerFileUrl.
        Returns:
        A new instance of SnowflakeFile for the given URL.
        Since:
        1.3.0
      • newInstance

        public static SnowflakeFile newInstance​(String url,
                                                boolean requireScopedUrl)
        Create a new instance of SnowflakeFile. Calls into our C++ layer to construct it.

        This method should be used when the UDF author (owner) intends to access their own files via a stage URL. If scoped URL is required, newInstance(scopedUrl) can be used. This method requires a scoped URL and is the same as calling newInstance(scopedUrl, /*requiredScopedUrl*\/=true).

        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 (requireScopedUrl=false) allows the caller to provide URLs that may be only accessible by the UDF owner.

        Parameters:
        url - scoped URL, file URL, or string path for files located in a stage
        requireScopedUrl - whether to fail if this URL is not a scoped URL
        Returns:
        A new instance of SnowflakeFile for the given URL.
        Since:
        1.8.0
      • newInstanceFromOwnerFileUrl

        @Deprecated
        public static SnowflakeFile newInstanceFromOwnerFileUrl​(String url)
        Deprecated.
        Use newInstance(String, bool) instead.
        Create a new instance of SnowflakeFile. Calls into our C++ layer to construct it.

        This method should be used when the UDF author (owner) intends to access their own files whereas the other method (newInstance) should be used when the UDF owner intends to access files passed into the function by the caller.

        All files are accessed in the context of the UDF owner and therefore implementation should prefer using the newInstance for callers files as it only allows scoped URLs and therefore a caller cannot inadvertently access the owner's files.

        Parameters:
        url - can be scoped URL or a stage file reference.
        Returns:
        A new instance of SnowflakeFile for the given URL.
        Since:
        1.8.0
      • getInputStream

        public InputStream getInputStream()
        Obtain and return the input stream for the file. Successive calls do not create a new input stream, but rather return the cached stream for the file.
        Returns:
        An InputStream for the SnowflakeFile.
        Since:
        1.3.0
      • getSize

        public Long getSize()
        Total size of the file obtained from the cloud storage provider when available, returns null otherwise.
        Returns:
        the size of the file, as provided by the cloud storage provider.
        Since:
        1.3.0