Package com.databricks.jdbc.api.impl.volume

## Class DatabricksUCVolumeClient

- java.lang.Object
- - com.databricks.jdbc.api.impl.volume.DatabricksUCVolumeClient

All Implemented Interfaces:
  `IDatabricksVolumeClient`

    public class DatabricksUCVolumeClient
    extends Object
    implements IDatabricksVolumeClient

Implementation of the VolumeClient that uses SQL query to perform the Volume Operations

### Constructor Summary

Constructors
`DatabricksUCVolumeClient​(Connection connection)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`boolean` `deleteObject​(String catalog, String schema, String volume, String objectPath)` Deletes an object from a specified path within a UC Volume.
`org.apache.http.entity.InputStreamEntity` `getObject​(String catalog, String schema, String volume, String objectPath)` Retrieves an object as an input stream from the UC Volume.
`boolean` `getObject​(String catalog, String schema, String volume, String objectPath, String localPath)` Downloads an object (file) from the UC Volume to a local path.
`static String` `getObjectFullPath​(String catalog, String schema, String volume, String objectPath)`
`List<String>` `listObjects​(String catalog, String schema, String volume, String prefix)`
`List<String>` `listObjects​(String catalog, String schema, String volume, String prefix, boolean caseSensitive)` This functions lists all the files that fall under the specified prefix within the target folder in the specified volume.
`boolean` `objectExists​(String catalog, String schema, String volume, String objectPath)`
`boolean` `objectExists​(String catalog, String schema, String volume, String objectPath, boolean caseSensitive)` Checks if a specific object (file) exists in the UC Volume.
`boolean` `prefixExists​(String catalog, String schema, String volume, String prefix)`
`boolean` `prefixExists​(String catalog, String schema, String volume, String prefix, boolean caseSensitive)` Checks if a specific prefix (folder-like structure) exists in the UC Volume.
`List<VolumePutResult>` `putFiles​(String catalog, String schema, String volume, List<String> objectPaths, List<InputStream> inputStreams, List<Long> contentLengths, boolean toOverwrite)` Uploads multiple files from input streams to specified paths within a UC Volume.
`List<VolumePutResult>` `putFiles​(String catalog, String schema, String volume, List<String> objectPaths, List<String> localPaths, boolean toOverwrite)` Uploads multiple files from local paths to specified paths within a UC Volume.
`boolean` `putObject​(String catalog, String schema, String volume, String objectPath, InputStream inputStream, long contentLength, boolean toOverwrite)` Uploads data from an input stream to a specified path within a UC Volume.
`boolean` `putObject​(String catalog, String schema, String volume, String objectPath, String localPath, boolean toOverwrite)` Uploads data from a local file to a specified path within a UC Volume.
`boolean` `volumeExists​(String catalog, String schema, String volumeName)`
`boolean` `volumeExists​(String catalog, String schema, String volumeName, boolean caseSensitive)` Checks if a specific volume exists in the given catalog and schema.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### DatabricksUCVolumeClient

    public DatabricksUCVolumeClient​(Connection connection)

### Method Detail

#### getObjectFullPath

    public static String getObjectFullPath​(String catalog,
                                           String schema,
                                           String volume,
                                           String objectPath)

#### prefixExists

    public boolean prefixExists​(String catalog,
                                String schema,
                                String volume,
                                String prefix)
                         throws SQLException

Throws:
  `SQLException`

#### prefixExists

    public boolean prefixExists​(String catalog,
                                String schema,
                                String volume,
                                String prefix,
                                boolean caseSensitive)
                         throws SQLException

Description copied from interface: `IDatabricksVolumeClient`
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.

Specified by:
  `prefixExists` in interface `IDatabricksVolumeClient`
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

    public boolean objectExists​(String catalog,
                                String schema,
                                String volume,
                                String objectPath,
                                boolean caseSensitive)
                         throws SQLException

Description copied from interface: `IDatabricksVolumeClient`
Checks if a specific object (file) exists in the UC Volume. The object path must exactly match an existing file.

Specified by:
  `objectExists` in interface `IDatabricksVolumeClient`
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

#### objectExists

    public boolean objectExists​(String catalog,
                                String schema,
                                String volume,
                                String objectPath)
                         throws SQLException

Throws:
  `SQLException`

#### volumeExists

    public boolean volumeExists​(String catalog,
                                String schema,
                                String volumeName,
                                boolean caseSensitive)
                         throws SQLException

Description copied from interface: `IDatabricksVolumeClient`
Checks if a specific volume exists in the given catalog and schema. The volume name must match exactly.

Specified by:
  `volumeExists` in interface `IDatabricksVolumeClient`
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

#### volumeExists

    public boolean volumeExists​(String catalog,
                                String schema,
                                String volumeName)
                         throws SQLException

Throws:
  `SQLException`

#### listObjects

    public List<String> listObjects​(String catalog,
                                    String schema,
                                    String volume,
                                    String prefix,
                                    boolean caseSensitive)
                             throws SQLException

This functions lists all the files that fall under the specified prefix within the target folder in the specified volume. The prefix is checked with the word after the last / in the input Ex - 1. foo/bar will list all the files within foo folder having bar as prefix | 2. foo/bar/f will list all the files within the bar folder with prefix f | 3. foo/bar/ will list all the files within the bar folder with all prefix

Specified by:
  `listObjects` in interface `IDatabricksVolumeClient`
Parameters:
  `catalog` - the catalog name of the cloud storage
  `schema` - the schema name of the cloud storage
  `volume` - the UC volume name of the cloud storage
  `prefix` - the prefix of the filenames to list. This includes the relative path from the volume as the root directory
  `caseSensitive` - a boolean indicating whether the check should be case-sensitive or not
Returns:
  List<String> a list of strings indicating the filenames that start with the specified prefix
Throws:
  `SQLException` - if a database access error occurs or the volume is inaccessible

#### listObjects

    public List<String> listObjects​(String catalog,
                                    String schema,
                                    String volume,
                                    String prefix)
                             throws SQLException

Throws:
  `SQLException`

#### getObject

    public boolean getObject​(String catalog,
                             String schema,
                             String volume,
                             String objectPath,
                             String localPath)
                      throws SQLException

Description copied from interface: `IDatabricksVolumeClient`
Downloads an object (file) from the UC Volume to a local path.

Specified by:
  `getObject` in interface `IDatabricksVolumeClient`
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

    public org.apache.http.entity.InputStreamEntity getObject​(String catalog,
                                                              String schema,
                                                              String volume,
                                                              String objectPath)
                                                       throws SQLException

Description copied from interface: `IDatabricksVolumeClient`
Retrieves an object as an input stream from the UC Volume. The caller is responsible for closing the returned input stream.

Specified by:
  `getObject` in interface `IDatabricksVolumeClient`
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

    public boolean putObject​(String catalog,
                             String schema,
                             String volume,
                             String objectPath,
                             String localPath,
                             boolean toOverwrite)
                      throws SQLException

Description copied from interface: `IDatabricksVolumeClient`
Uploads data from a local file to a specified path within a UC Volume.

Specified by:
  `putObject` in interface `IDatabricksVolumeClient`
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

    public boolean putObject​(String catalog,
                             String schema,
                             String volume,
                             String objectPath,
                             InputStream inputStream,
                             long contentLength,
                             boolean toOverwrite)
                      throws SQLException

Description copied from interface: `IDatabricksVolumeClient`
Uploads data from an input stream to a specified path within a UC Volume.

Specified by:
  `putObject` in interface `IDatabricksVolumeClient`
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

    public boolean deleteObject​(String catalog,
                                String schema,
                                String volume,
                                String objectPath)
                         throws SQLException

Description copied from interface: `IDatabricksVolumeClient`
Deletes an object from a specified path within a UC Volume.

Specified by:
  `deleteObject` in interface `IDatabricksVolumeClient`
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

    public List<VolumePutResult> putFiles​(String catalog,
                                          String schema,
                                          String volume,
                                          List<String> objectPaths,
                                          List<InputStream> inputStreams,
                                          List<Long> contentLengths,
                                          boolean toOverwrite)
                                   throws DatabricksSQLFeatureNotSupportedException

Description copied from interface: `IDatabricksVolumeClient`
Uploads multiple files from input streams to specified paths within a UC Volume.

Specified by:
  `putFiles` in interface `IDatabricksVolumeClient`
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

    public List<VolumePutResult> putFiles​(String catalog,
                                          String schema,
                                          String volume,
                                          List<String> objectPaths,
                                          List<String> localPaths,
                                          boolean toOverwrite)
                                   throws DatabricksSQLFeatureNotSupportedException

Description copied from interface: `IDatabricksVolumeClient`
Uploads multiple files from local paths to specified paths within a UC Volume.

Specified by:
  `putFiles` in interface `IDatabricksVolumeClient`
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