Class DatabricksBatchExecutor


  • public class DatabricksBatchExecutor
    extends Object
    The DatabricksBatchExecutor class handles the execution of batch SQL commands. It encapsulates batch logic, maintains the list of commands, and manages the execution flow.

    This class is responsible for:

    • Adding commands to the batch.
    • Clearing the batch commands.
    • Executing the batch and handling exceptions according to JDBC specifications.
    • Tracking telemetry such as execution time for each command and total batch execution time.
    • Enforcing a maximum batch size limit.
    • Constructor Detail

      • DatabricksBatchExecutor

        public DatabricksBatchExecutor​(Statement parentStatement,
                                       int maxBatchSize)
        Constructs a DatabricksBatchExecutor with the specified parent Statement and maximum batch size.
        Parameters:
        parentStatement - the parent Statement that will execute the commands
        maxBatchSize - the maximum number of commands allowed in the batch
    • Method Detail

      • clearCommands

        public void clearCommands()
        Clears all the commands from the batch.
      • executeBatch

        public long[] executeBatch()
                            throws DatabricksBatchUpdateException
        Executes all the commands in the batch sequentially. If any command fails or attempts to return a ResultSet, the execution stops, and a BatchUpdateException is thrown.

        The driver stops execution upon encountering a failure and does not process subsequent commands. This method also tracks and logs telemetry data such as execution time for each command and total batch time.

        Returns:
        an array of update counts for each command in the batch
        Throws:
        DatabricksBatchUpdateException - if a database access error occurs or batch execution fails