Package com.databend.jdbc
Interface DatabendConnectionExtension
-
- All Known Implementing Classes:
DatabendConnection
public interface DatabendConnectionExtensionThe 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 Modifier and Type Interface Description static classDatabendConnectionExtension.LoadMethodEnumeration of available loading strategies for streaming data into tables.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description InputStreamdownloadStream(String stageName, String sourceFileName)Download a file from the databend internal stage, the data would be downloaded as one file with no split.intloadStreamToTable(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.voiduploadStream(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.voiduploadStream(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 filedestPrefix- the prefix of the file name in the stageinputStream- the input stream of the filedestFileName- the destination file name in the stagefileSize- the file size in the stagecompressData- 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 filesourceFileName- 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 viaDatabendConnectionExtension.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 tablefileSize- Size of the data (in bytes) to be loadedloadMethod- Loading strategy (DatabendConnectionExtension.LoadMethod.STAGEorDatabendConnectionExtension.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)
-
-