Package com.databend.jdbc

## Interface DatabendConnectionExtension

All Known Implementing Classes:
  `DatabendConnection`

    public interface DatabendConnectionExtension

The SnowflakeConnection interface contains Snowflake-specific methods. providing specialized methods for interacting with Databend stages and loading data efficiently.

This interface extends standard JDBC connection capabilities to support streaming operations for uploading/downloading files to/from internal stages, as well as direct streaming data loading into target tables. Ideal for handling large files or continuous data streams in Databend.

### Nested Class Summary

Nested Classes
`static class` `DatabendConnectionExtension.LoadMethod` Enumeration of available loading strategies for streaming data into tables.

### Method Summary

All Methods Instance Methods Abstract Methods
`InputStream` `downloadStream​(String stageName, String sourceFileName)` Download a file from the databend internal stage, the data would be downloaded as one file with no split.
`int` `loadStreamToTable​(String sql, InputStream inputStream, long fileSize, DatabendConnectionExtension.LoadMethod loadMethod)` Loads data from an input stream directly into a target Databend table using the specified SQL command.
`void` `uploadStream​(InputStream inputStream, String stageName, String destPrefix, String destFileName, long fileSize, boolean compressData)` Upload inputStream to the databend internal stage, the data would be uploaded as one file with no split.
`void` `uploadStream​(String stageName, String destPrefix, InputStream inputStream, String destFileName, long fileSize, boolean compressData)`

### Method Detail

#### uploadStream

    void uploadStream​(String stageName,
                      String destPrefix,
                      InputStream inputStream,
                      String destFileName,
                      long fileSize,
                      boolean compressData)
               throws SQLException

Throws:
  `SQLException`

#### uploadStream

    void uploadStream​(InputStream inputStream,
                      String stageName,
                      String destPrefix,
                      String destFileName,
                      long fileSize,
                      boolean compressData)
               throws SQLException

Upload inputStream to the databend internal stage, the data would be uploaded as one file with no split. Caller should close the input stream after the upload is done.

Parameters:
  `stageName` - the stage which receive uploaded file
  `destPrefix` - the prefix of the file name in the stage
  `inputStream` - the input stream of the file
  `destFileName` - the destination file name in the stage
  `fileSize` - the file size in the stage
  `compressData` - whether to compress the data
Throws:
  `SQLException` - failed to upload input stream

#### downloadStream

    InputStream downloadStream​(String stageName,
                               String sourceFileName)
                        throws SQLException

Download a file from the databend internal stage, the data would be downloaded as one file with no split.

Parameters:
  `stageName` - the stage which contains the file
  `sourceFileName` - the file name in the stage
Returns:
  the input stream of the file
Throws:
  `SQLException` - failed to download input stream

#### loadStreamToTable

    int loadStreamToTable​(String sql,
                          InputStream inputStream,
                          long fileSize,
                          DatabendConnectionExtension.LoadMethod loadMethod)
                   throws SQLException

Loads data from an input stream directly into a target Databend table using the specified SQL command. Supports two loading strategies via `DatabendConnectionExtension.LoadMethod`.

Parameters:
  `sql` - SQL command with Databend's load syntax: `INSERT INTO <table> [(<columns>)] FROM @_databend_load [file_format=(...)]`
  `inputStream` - Input stream containing the data to load into the table
  `fileSize` - Size of the data (in bytes) to be loaded
  `loadMethod` - Loading strategy (`DatabendConnectionExtension.LoadMethod.STAGE` or `DatabendConnectionExtension.LoadMethod.STREAMING`)
Returns:
  Number of rows successfully loaded into the target table
Throws:
  `SQLException` - If the load operation fails (e.g., invalid SQL, stream errors, or data format issues)