Class 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 Detail

      • InsertStatementParser

        public InsertStatementParser()
    • Method Detail

      • 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
      • 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