Skip to content

Commit 3d37760

Browse files
authored
[PECOBLR-310] Refactor internal interfaces into internal package, and fix javadoc for public interfaces (#770)
* Fix javadoc for all public interfaces
1 parent 4a3aef7 commit 3d37760

File tree

94 files changed

+263
-204
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+263
-204
lines changed

src/main/java/com/databricks/client/jdbc/Driver.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import static com.databricks.jdbc.telemetry.TelemetryHelper.*;
44

5-
import com.databricks.jdbc.api.IDatabricksConnectionContext;
65
import com.databricks.jdbc.api.impl.DatabricksConnection;
76
import com.databricks.jdbc.api.impl.DatabricksConnectionContextFactory;
7+
import com.databricks.jdbc.api.internal.IDatabricksConnectionContext;
88
import com.databricks.jdbc.common.DatabricksClientType;
99
import com.databricks.jdbc.common.util.*;
1010
import com.databricks.jdbc.dbclient.IDatabricksClient;
@@ -15,7 +15,6 @@
1515
import com.databricks.jdbc.log.JdbcLogger;
1616
import com.databricks.jdbc.log.JdbcLoggerFactory;
1717
import com.databricks.jdbc.model.telemetry.enums.DatabricksDriverErrorCode;
18-
import java.sql.*;
1918
import java.sql.Connection;
2019
import java.sql.DriverManager;
2120
import java.sql.DriverPropertyInfo;

src/main/java/com/databricks/jdbc/api/IDatabricksConnection.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,29 @@
44
import java.sql.SQLException;
55
import java.sql.Statement;
66

7+
/**
8+
* Extends the standard JDBC {@link Connection} interface to provide Databricks-specific
9+
* functionality. This interface adds methods to retrieve statement handles and connection
10+
* identifiers.
11+
*/
712
public interface IDatabricksConnection extends Connection {
813

9-
/** Returns the statement handle for given statement-Id */
14+
/**
15+
* Retrieves a statement handle for a given statement ID.
16+
*
17+
* @param statementId The unique identifier of the statement to retrieve
18+
* @return A {@link Statement} object representing the statement
19+
* @throws SQLException if a database access error occurs or this method is called on a closed
20+
* connection
21+
*/
1022
Statement getStatement(String statementId) throws SQLException;
1123

12-
/** Returns the connection-Id for the connection */
24+
/**
25+
* Retrieves the unique identifier for this connection.
26+
*
27+
* @return A string representing the unique connection ID
28+
* @throws SQLException if a database access error occurs or this method is called on a closed
29+
* connection
30+
*/
1331
String getConnectionId() throws SQLException;
1432
}

src/main/java/com/databricks/jdbc/api/IDatabricksResultSet.java

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,63 @@
66
import java.sql.Struct;
77
import java.util.Map;
88

9-
/** Extension to java.sql.ResultSet interface */
9+
/**
10+
* Extends the standard JDBC {@link ResultSet} interface to provide Databricks-specific
11+
* functionality. This interface adds support for complex data types like Structs and Maps, as well
12+
* as methods to retrieve statement status and execution information.
13+
*/
1014
public interface IDatabricksResultSet extends ResultSet {
1115

16+
/**
17+
* Retrieves the SQL `Struct` from the specified column using its label.
18+
*
19+
* @param columnLabel the label for the column specified in the SQL query
20+
* @return a `Struct` object if the column contains a struct; `null` if the value is SQL `NULL`
21+
* @throws SQLException if the column is not of `STRUCT` type or if any SQL error occurs
22+
*/
1223
Struct getStruct(String columnLabel) throws SQLException;
1324

14-
Map<String, Object> getMap(String columbLabel) throws SQLException;
25+
/**
26+
* Retrieves the SQL `Map` from the specified column using its label.
27+
*
28+
* @param columnLabel the label for the column specified in the SQL query
29+
* @return a `Map<String, Object>` if the column contains a map; `null` if the value is SQL `NULL`
30+
* @throws SQLException if the column is not of `MAP` type or if any SQL error occurs
31+
*/
32+
Map<String, Object> getMap(String columnLabel) throws SQLException;
1533

1634
/**
17-
* Returns statement-Id of associated statement
35+
* Retrieves the unique identifier of the statement associated with this result set.
1836
*
19-
* @return statement-Id
37+
* @return A string representing the statement ID
2038
*/
2139
String getStatementId();
2240

2341
/**
24-
* Fetches Statement status for underlying statement
42+
* Retrieves the current status of the statement associated with this result set. This can be used
43+
* to monitor the execution progress and state of the statement.
2544
*
26-
* @return statement status
45+
* @return The current {@link StatementStatus} of the statement
2746
*/
2847
StatementStatus getStatementStatus();
2948

3049
/**
31-
* Returns update count for underlying statement execution. Returns 0 for a query statement.
50+
* Retrieves the number of rows affected by the SQL statement. For SELECT statements or statements
51+
* that don't modify data, this will return 0.
3252
*
33-
* @return update count
34-
* @throws SQLException
53+
* @return The number of rows affected by INSERT, UPDATE, or DELETE statements
54+
* @throws SQLException if a database access error occurs or this method is called on a closed
55+
* result set
3556
*/
3657
long getUpdateCount() throws SQLException;
3758

3859
/**
39-
* Checks if there is an update count for underlying statement execution
60+
* Checks whether the executed SQL statement has produced an update count. This is typically true
61+
* for DML (Data Manipulation Language) statements like INSERT, UPDATE, or DELETE.
4062
*
41-
* @return true for DML commands
42-
* @throws SQLException
63+
* @return true if the statement has produced an update count, false otherwise
64+
* @throws SQLException if a database access error occurs or this method is called on a closed
65+
* result set
4366
*/
4467
boolean hasUpdateCount() throws SQLException;
4568

src/main/java/com/databricks/jdbc/api/IDatabricksStatement.java

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,35 @@
44
import java.sql.SQLException;
55
import java.sql.Statement;
66

7-
/** Interface for Databricks specific statement. */
7+
/**
8+
* Extends the standard JDBC {@link Statement} interface to provide Databricks-specific
9+
* functionality. This interface adds support for asynchronous query execution and result retrieval,
10+
* allowing for better handling of long-running queries and improved performance in distributed
11+
* environments.
12+
*/
813
public interface IDatabricksStatement extends Statement {
914

1015
/**
11-
* Executes the given SQL command in async mode, and returns a lightweight instance of result set
16+
* Executes the given SQL command asynchronously and returns a lightweight result set handle. This
17+
* method initiates the execution but does not wait for it to complete, making it suitable for
18+
* long-running queries. The actual results can be retrieved later using {@link
19+
* #getExecutionResult()}.
1220
*
13-
* @param sql SQL command to be executed
14-
* @return result set for given execution
15-
* @throws SQLException in case of error
21+
* @param sql The SQL command to be executed
22+
* @return A {@link ResultSet} handle that can be used to track and retrieve the results
23+
* @throws SQLException if a database access error occurs, this method is called on a closed
24+
* statement, or the SQL command is not valid
1625
*/
1726
ResultSet executeAsync(String sql) throws SQLException;
1827

1928
/**
20-
* Returns result set response for the executed statement
29+
* Retrieves the result set for a previously executed statement. This method should be called
30+
* after executing a statement using {@link #executeAsync(String)} to get the actual results.
2131
*
22-
* @return result set for underlying execution
23-
* @throws SQLException if statement was never executed
32+
* @return A {@link ResultSet} containing the results of the statement execution in case of
33+
* successful completion, else handle for the result status.
34+
* @throws SQLException if the statement was never executed, has been closed, or if a database
35+
* access error occurs
2436
*/
2537
ResultSet getExecutionResult() throws SQLException;
2638
}

src/main/java/com/databricks/jdbc/api/IDatabricksVolumeClient.java

Lines changed: 85 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -5,106 +5,118 @@
55
import java.util.List;
66
import org.apache.http.entity.InputStreamEntity;
77

8+
/**
9+
* Interface for interacting with Databricks Unity Catalog (UC) Volumes. Provides methods for
10+
* managing and accessing files and directories within UC Volumes, supporting operations such as
11+
* checking existence, listing contents, and performing CRUD (Create, Read, Update, Delete)
12+
* operations on objects stored in volumes.
13+
*/
814
public interface IDatabricksVolumeClient {
915

1016
/**
11-
* prefixExists(): Determines if a specific prefix (folder-like structure) exists in the UC Volume
12-
* The prefix that we are looking for must be a part of the file name.
17+
* Checks if a specific prefix (folder-like structure) exists in the UC Volume. The prefix must be
18+
* a part of the file name or path.
1319
*
14-
* @param catalog the catalog name of the cloud storage
15-
* @param schema the schema name of the cloud storage
16-
* @param volume the UC volume name of the cloud storage
17-
* @param prefix the prefix to check for existence along with the relative path from the volume as
18-
* the root directory
19-
* @param caseSensitive a boolean indicating whether the check should be case-sensitive or not
20-
* @return a boolean indicating whether the prefix exists or not
20+
* @param catalog the catalog name in Unity Catalog
21+
* @param schema the schema name in the specified catalog
22+
* @param volume the volume name in the specified schema
23+
* @param prefix the prefix to check, including the relative path from the volume root
24+
* @param caseSensitive whether the prefix check should be case-sensitive
25+
* @return true if the prefix exists, false otherwise
26+
* @throws SQLException if a database access error occurs or the volume is inaccessible
2127
*/
2228
boolean prefixExists(
2329
String catalog, String schema, String volume, String prefix, boolean caseSensitive)
2430
throws SQLException;
2531

2632
/**
27-
* objectExists(): Determines if a specific object (file) exists in the UC Volume The object that
28-
* we are looking for must match the file name exactly
33+
* Checks if a specific object (file) exists in the UC Volume. The object path must exactly match
34+
* an existing file.
2935
*
30-
* @param catalog the catalog name of the cloud storage
31-
* @param schema the schema name of the cloud storage
32-
* @param volume the UC volume name of the cloud storage
33-
* @param objectPath the path of the object (file) from the volume as the root directory to check
34-
* for existence within the volume (inside any sub-folder)
35-
* @param caseSensitive a boolean indicating whether the check should be case-sensitive or not
36-
* @return a boolean indicating whether the object exists or not
36+
* @param catalog the catalog name in Unity Catalog
37+
* @param schema the schema name in the specified catalog
38+
* @param volume the volume name in the specified schema
39+
* @param objectPath the path of the object from the volume root
40+
* @param caseSensitive whether the path check should be case-sensitive
41+
* @return true if the object exists, false otherwise
42+
* @throws SQLException if a database access error occurs or the volume is inaccessible
3743
*/
3844
boolean objectExists(
3945
String catalog, String schema, String volume, String objectPath, boolean caseSensitive)
4046
throws SQLException;
4147

4248
/**
43-
* volumeExists(): Determines if a specific volume exists in the given catalog and schema. The
44-
* volume that we are looking for must match the volume name exactly.
49+
* Checks if a specific volume exists in the given catalog and schema. The volume name must match
50+
* exactly.
4551
*
46-
* @param catalog the catalog name of the cloud storage
47-
* @param schema the schema name of the cloud storage
48-
* @param volumeName the name of the volume to check for existence
49-
* @param caseSensitive a boolean indicating whether the check should be case-sensitive or not
50-
* @return a boolean indicating whether the volume exists or not
52+
* @param catalog the catalog name in Unity Catalog
53+
* @param schema the schema name in the specified catalog
54+
* @param volumeName the name of the volume to check
55+
* @param caseSensitive whether the volume name check should be case-sensitive
56+
* @return true if the volume exists, false otherwise
57+
* @throws SQLException if a database access error occurs
5158
*/
5259
boolean volumeExists(String catalog, String schema, String volumeName, boolean caseSensitive)
5360
throws SQLException;
5461

5562
/**
56-
* listObjects(): Lists all filenames in the UC Volume that start with a specified prefix. The
57-
* prefix that we are looking for must be a part of the file path from the volume as the root.
63+
* Lists all objects (files) in the UC Volume that start with a specified prefix. The prefix must
64+
* be a part of the file path from the volume root.
5865
*
59-
* @param catalog the catalog name of the cloud storage
60-
* @param schema the schema name of the cloud storage
61-
* @param volume the UC volume name of the cloud storage
62-
* @param prefix the prefix of the filenames to list. This includes the relative path from the
63-
* volume as the root directory
64-
* @param caseSensitive a boolean indicating whether the check should be case-sensitive or not
65-
* @return a list of strings indicating the filenames that start with the specified prefix
66+
* @param catalog the catalog name in Unity Catalog
67+
* @param schema the schema name in the specified catalog
68+
* @param volume the volume name in the specified schema
69+
* @param prefix the prefix to filter objects by, including the relative path from volume root
70+
* @param caseSensitive whether the prefix matching should be case-sensitive
71+
* @return a list of object paths that match the specified prefix
72+
* @throws SQLException if a database access error occurs or the volume is inaccessible
6673
*/
6774
List<String> listObjects(
6875
String catalog, String schema, String volume, String prefix, boolean caseSensitive)
6976
throws SQLException;
7077

7178
/**
72-
* getObject(): Retrieves an object (file) from the UC Volume and stores it in the local path
79+
* Downloads an object (file) from the UC Volume to a local path.
7380
*
74-
* @param catalog the catalog name of the cloud storage
75-
* @param schema the schema name of the cloud storage
76-
* @param volume the UC volume name of the cloud storage
77-
* @param objectPath the path of the object (file) from the volume as the root directory
78-
* @param localPath the local path where the retrieved data is to be stored
79-
* @return a boolean value indicating status of the GET operation
81+
* @param catalog the catalog name in Unity Catalog
82+
* @param schema the schema name in the specified catalog
83+
* @param volume the volume name in the specified schema
84+
* @param objectPath the path of the object in the volume
85+
* @param localPath the local filesystem path where the object should be saved
86+
* @return true if the download was successful, false otherwise
87+
* @throws SQLException if a database access error occurs, the volume is inaccessible, or there
88+
* are issues with the local filesystem
8089
*/
8190
boolean getObject(
8291
String catalog, String schema, String volume, String objectPath, String localPath)
8392
throws SQLException;
8493

8594
/**
86-
* getObject(): Retrieves an object as input stream from the UC Volume
95+
* Retrieves an object as an input stream from the UC Volume. The caller is responsible for
96+
* closing the returned input stream.
8797
*
88-
* @param catalog the catalog name of the cloud storage
89-
* @param schema the schema name of the cloud storage
90-
* @param volume the UC volume name of the cloud storage
91-
* @param objectPath the path of the object (file) from the volume as the root directory
92-
* @return an instance of input stream entity
98+
* @param catalog the catalog name in Unity Catalog
99+
* @param schema the schema name in the specified catalog
100+
* @param volume the volume name in the specified schema
101+
* @param objectPath the path of the object in the volume
102+
* @return an InputStreamEntity containing the object's data
103+
* @throws SQLException if a database access error occurs or the volume is inaccessible
93104
*/
94105
InputStreamEntity getObject(String catalog, String schema, String volume, String objectPath)
95106
throws SQLException;
96107

97108
/**
98-
* putObject(): Upload data from a local path to a specified path within a UC Volume.
109+
* Uploads data from a local file to a specified path within a UC Volume.
99110
*
100-
* @param catalog the catalog name of the cloud storage
101-
* @param schema the schema name of the cloud storage
102-
* @param volume the UC volume name of the cloud storage
103-
* @param objectPath the destination path where the object (file) is to be uploaded from the
104-
* volume as the root directory
105-
* @param localPath the local path from where the data is to be uploaded
106-
* @param toOverwrite a boolean indicating whether to overwrite the object if it already exists
107-
* @return a boolean value indicating status of the PUT operation
111+
* @param catalog the catalog name in Unity Catalog
112+
* @param schema the schema name in the specified catalog
113+
* @param volume the volume name in the specified schema
114+
* @param objectPath the destination path in the volume where the file should be uploaded
115+
* @param localPath the local filesystem path of the file to upload
116+
* @param toOverwrite whether to overwrite the object if it already exists
117+
* @return true if the upload was successful, false otherwise
118+
* @throws SQLException if a database access error occurs, the volume is inaccessible, or there
119+
* are issues with the local filesystem
108120
*/
109121
boolean putObject(
110122
String catalog,
@@ -116,17 +128,17 @@ boolean putObject(
116128
throws SQLException;
117129

118130
/**
119-
* putObject(): Upload data from an input stream to a specified path within a UC Volume.
131+
* Uploads data from an input stream to a specified path within a UC Volume.
120132
*
121-
* @param catalog the catalog name of the cloud storage
122-
* @param schema the schema name of the cloud storage
123-
* @param volume the UC volume name of the cloud storage
124-
* @param objectPath the destination path where the object (file) is to be uploaded from the
125-
* volume as the root directory
126-
* @param inputStream the input stream from where the data is to be uploaded
127-
* @param contentLength the length of the input stream
128-
* @param toOverwrite a boolean indicating whether to overwrite the object if it already exists
129-
* @return a boolean value indicating status of the PUT operation
133+
* @param catalog the catalog name in Unity Catalog
134+
* @param schema the schema name in the specified catalog
135+
* @param volume the volume name in the specified schema
136+
* @param objectPath the destination path in the volume where the data should be uploaded
137+
* @param inputStream the input stream containing the data to upload
138+
* @param contentLength the length of the data in bytes
139+
* @param toOverwrite whether to overwrite the object if it already exists
140+
* @return true if the upload was successful, false otherwise
141+
* @throws SQLException if a database access error occurs or the volume is inaccessible
130142
*/
131143
boolean putObject(
132144
String catalog,
@@ -139,13 +151,14 @@ boolean putObject(
139151
throws SQLException;
140152

141153
/**
142-
* deleteObject(): Remove an object from a specified path within a UC Volume
154+
* Deletes an object from a specified path within a UC Volume.
143155
*
144-
* @param catalog the catalog name of the cloud storage
145-
* @param schema the schema name of the cloud storage
146-
* @param volume the UC volume name of the cloud storage
147-
* @param objectPath the path of the object (file) from the volume as the root directory to delete
148-
* @return a boolean value indicating status of the DELETE operation
156+
* @param catalog the catalog name in Unity Catalog
157+
* @param schema the schema name in the specified catalog
158+
* @param volume the volume name in the specified schema
159+
* @param objectPath the path of the object to delete
160+
* @return true if the deletion was successful, false otherwise
161+
* @throws SQLException if a database access error occurs or the volume is inaccessible
149162
*/
150163
boolean deleteObject(String catalog, String schema, String volume, String objectPath)
151164
throws SQLException;

0 commit comments

Comments
 (0)