Class InsertStatementParser

java.lang.Object
com.databricks.jdbc.common.util.InsertStatementParser

public class InsertStatementParser extends Object
Utility class for parsing INSERT statements to extract table and column information. Supports detecting compatible INSERT statements that can be combined into multi-row batches.
  • Constructor Details

    • InsertStatementParser

      public InsertStatementParser()
  • Method Details

    • parseInsert

      public static InsertStatementParser.InsertInfo parseInsert(String sql)
      Parses an INSERT statement to extract table and column information.
      Parameters:
      sql - the INSERT SQL statement to parse
      Returns:
      InsertInfo object containing parsed information, or null if not a valid INSERT
    • parseInsertStrict

      public static InsertStatementParser.InsertInfo parseInsertStrict(String sql) throws DatabricksParsingException
      Parses an INSERT statement to extract table and column information with strict error handling.
      Parameters:
      sql - the INSERT SQL statement to parse
      Returns:
      InsertInfo object containing parsed information
      Throws:
      DatabricksParsingException - if the SQL is not a properly formatted INSERT statement
    • isParametrizedInsert

      public static boolean isParametrizedInsert(String sql)
      Checks if the given SQL statement is a parametrized INSERT statement suitable for batching.
      Parameters:
      sql - the SQL statement to check
      Returns:
      true if it's a parametrized INSERT that can be batched, false otherwise
    • generateMultiRowInsert

      public static String generateMultiRowInsert(InsertStatementParser.InsertInfo insertInfo, int numberOfRows) throws DatabricksParsingException
      Generates a multi-row INSERT statement from the template and number of rows.
      Parameters:
      insertInfo - the parsed INSERT information
      numberOfRows - the number of rows to include in the batch
      Returns:
      the multi-row INSERT SQL statement
      Throws:
      DatabricksParsingException - if insertInfo is null or numberOfRows is invalid