Package com.databricks.jdbc.common.util
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classInsertStatementParser.InsertInfoRepresents the parsed components of an INSERT statement.
-
Constructor Summary
Constructors Constructor Description InsertStatementParser()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringgenerateMultiRowInsert(InsertStatementParser.InsertInfo insertInfo, int numberOfRows)Generates a multi-row INSERT statement from the template and number of rows.static booleanisParametrizedInsert(String sql)Checks if the given SQL statement is a parametrized INSERT statement suitable for batching.static InsertStatementParser.InsertInfoparseInsert(String sql)Parses an INSERT statement to extract table and column information.static InsertStatementParser.InsertInfoparseInsertStrict(String sql)Parses an INSERT statement to extract table and column information with strict error handling.
-
-
-
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
-
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 informationnumberOfRows- 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
-
-