Interface IDatabricksVolumeClient

  • All Known Implementing Classes:
    DatabricksUCVolumeClient, DBFSVolumeClient

    public interface IDatabricksVolumeClient
    Interface for interacting with Databricks Unity Catalog (UC) Volumes. Provides methods for managing and accessing files and directories within UC Volumes, supporting operations such as checking existence, listing contents, and performing CRUD (Create, Read, Update, Delete) operations on objects stored in volumes.
    • Method Detail

      • prefixExists

        boolean prefixExists​(String catalog,
                             String schema,
                             String volume,
                             String prefix,
                             boolean caseSensitive)
                      throws SQLException
        Checks if a specific prefix (folder-like structure) exists in the UC Volume. The prefix must be a part of the file name or path.
        Parameters:
        catalog - the catalog name in Unity Catalog
        schema - the schema name in the specified catalog
        volume - the volume name in the specified schema
        prefix - the prefix to check, including the relative path from the volume root
        caseSensitive - whether the prefix check should be case-sensitive
        Returns:
        true if the prefix exists, false otherwise
        Throws:
        SQLException - if a database access error occurs or the volume is inaccessible
      • objectExists

        boolean objectExists​(String catalog,
                             String schema,
                             String volume,
                             String objectPath,
                             boolean caseSensitive)
                      throws SQLException
        Checks if a specific object (file) exists in the UC Volume. The object path must exactly match an existing file.
        Parameters:
        catalog - the catalog name in Unity Catalog
        schema - the schema name in the specified catalog
        volume - the volume name in the specified schema
        objectPath - the path of the object from the volume root
        caseSensitive - whether the path check should be case-sensitive
        Returns:
        true if the object exists, false otherwise
        Throws:
        SQLException - if a database access error occurs or the volume is inaccessible
      • volumeExists

        boolean volumeExists​(String catalog,
                             String schema,
                             String volumeName,
                             boolean caseSensitive)
                      throws SQLException
        Checks if a specific volume exists in the given catalog and schema. The volume name must match exactly.
        Parameters:
        catalog - the catalog name in Unity Catalog
        schema - the schema name in the specified catalog
        volumeName - the name of the volume to check
        caseSensitive - whether the volume name check should be case-sensitive
        Returns:
        true if the volume exists, false otherwise
        Throws:
        SQLException - if a database access error occurs
      • listObjects

        List<String> listObjects​(String catalog,
                                 String schema,
                                 String volume,
                                 String prefix,
                                 boolean caseSensitive)
                          throws SQLException
        Lists all objects (files) in the UC Volume that start with a specified prefix. The prefix must be a part of the file path from the volume root.
        Parameters:
        catalog - the catalog name in Unity Catalog
        schema - the schema name in the specified catalog
        volume - the volume name in the specified schema
        prefix - the prefix to filter objects by, including the relative path from volume root
        caseSensitive - whether the prefix matching should be case-sensitive
        Returns:
        a list of object paths that match the specified prefix
        Throws:
        SQLException - if a database access error occurs or the volume is inaccessible
      • getObject

        boolean getObject​(String catalog,
                          String schema,
                          String volume,
                          String objectPath,
                          String localPath)
                   throws SQLException
        Downloads an object (file) from the UC Volume to a local path.
        Parameters:
        catalog - the catalog name in Unity Catalog
        schema - the schema name in the specified catalog
        volume - the volume name in the specified schema
        objectPath - the path of the object in the volume
        localPath - the local filesystem path where the object should be saved
        Returns:
        true if the download was successful, false otherwise
        Throws:
        SQLException - if a database access error occurs, the volume is inaccessible, or there are issues with the local filesystem
      • getObject

        org.apache.http.entity.InputStreamEntity getObject​(String catalog,
                                                           String schema,
                                                           String volume,
                                                           String objectPath)
                                                    throws SQLException
        Retrieves an object as an input stream from the UC Volume. The caller is responsible for closing the returned input stream.
        Parameters:
        catalog - the catalog name in Unity Catalog
        schema - the schema name in the specified catalog
        volume - the volume name in the specified schema
        objectPath - the path of the object in the volume
        Returns:
        an InputStreamEntity containing the object's data
        Throws:
        SQLException - if a database access error occurs or the volume is inaccessible
      • putObject

        boolean putObject​(String catalog,
                          String schema,
                          String volume,
                          String objectPath,
                          String localPath,
                          boolean toOverwrite)
                   throws SQLException
        Uploads data from a local file to a specified path within a UC Volume.
        Parameters:
        catalog - the catalog name in Unity Catalog
        schema - the schema name in the specified catalog
        volume - the volume name in the specified schema
        objectPath - the destination path in the volume where the file should be uploaded
        localPath - the local filesystem path of the file to upload
        toOverwrite - whether to overwrite the object if it already exists
        Returns:
        true if the upload was successful, false otherwise
        Throws:
        SQLException - if a database access error occurs, the volume is inaccessible, or there are issues with the local filesystem
      • putObject

        boolean putObject​(String catalog,
                          String schema,
                          String volume,
                          String objectPath,
                          InputStream inputStream,
                          long contentLength,
                          boolean toOverwrite)
                   throws SQLException
        Uploads data from an input stream to a specified path within a UC Volume.
        Parameters:
        catalog - the catalog name in Unity Catalog
        schema - the schema name in the specified catalog
        volume - the volume name in the specified schema
        objectPath - the destination path in the volume where the data should be uploaded
        inputStream - the input stream containing the data to upload
        contentLength - the length of the data in bytes
        toOverwrite - whether to overwrite the object if it already exists
        Returns:
        true if the upload was successful, false otherwise
        Throws:
        SQLException - if a database access error occurs or the volume is inaccessible
      • deleteObject

        boolean deleteObject​(String catalog,
                             String schema,
                             String volume,
                             String objectPath)
                      throws SQLException
        Deletes an object from a specified path within a UC Volume.
        Parameters:
        catalog - the catalog name in Unity Catalog
        schema - the schema name in the specified catalog
        volume - the volume name in the specified schema
        objectPath - the path of the object to delete
        Returns:
        true if the deletion was successful, false otherwise
        Throws:
        SQLException - if a database access error occurs or the volume is inaccessible
      • putFiles

        List<VolumePutResult> putFiles​(String catalog,
                                       String schema,
                                       String volume,
                                       List<String> objectPaths,
                                       List<InputStream> inputStreams,
                                       List<Long> contentLengths,
                                       boolean toOverwrite)
                                throws DatabricksSQLFeatureNotSupportedException
        Uploads multiple files from input streams to specified paths within a UC Volume.
        Parameters:
        catalog - the catalog name in Unity Catalog
        schema - the schema name in the specified catalog
        volume - the volume name in the specified schema
        objectPaths - the list of destination paths in the volume where the data should be uploaded
        inputStreams - the list of input streams containing the data to upload
        contentLengths - the list of lengths of the data in bytes
        toOverwrite - whether to overwrite the objects if they already exist
        Returns:
        a list of results indicating the success or failure of each upload operation
        Throws:
        DatabricksSQLFeatureNotSupportedException - if the operation is not supported
      • putFiles

        List<VolumePutResult> putFiles​(String catalog,
                                       String schema,
                                       String volume,
                                       List<String> objectPaths,
                                       List<String> localPaths,
                                       boolean toOverwrite)
                                throws DatabricksSQLFeatureNotSupportedException
        Uploads multiple files from local paths to specified paths within a UC Volume.
        Parameters:
        catalog - the catalog name in Unity Catalog
        schema - the schema name in the specified catalog
        volume - the volume name in the specified schema
        objectPaths - the list of destination paths in the volume where the files should be uploaded
        localPaths - the list of local file paths to upload
        toOverwrite - whether to overwrite the objects if they already exist
        Returns:
        a list of results indicating the success or failure of each upload operation
        Throws:
        DatabricksSQLFeatureNotSupportedException - if the operation is not supported