Package com.firebolt.jdbc.statement
Class StatementUtil
java.lang.Object
com.firebolt.jdbc.statement.StatementUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionExtract the database name and the table name from the cleaned sql queryextractParamFromSetStatement
(@NonNull String cleanSql, String sql) Extracts parameter from statement (eg: SET x=y)Returns the positions of the params markersstatic boolean
Returns true if the statement is a query (eg: SELECT, SHOW).Parse sql statement to aRawStatementWrapper
.Parse the sql statement to a list ofStatementInfoWrapper
replaceParameterMarksWithValues
(@NonNull Map<Integer, String> params, @NonNull RawStatementWrapper rawStatement) Returns a list ofStatementInfoWrapper
containing sql statements constructed with theRawStatementWrapper
and the parameters providedstatic List<StatementInfoWrapper>
replaceParameterMarksWithValues
(@NonNull Map<Integer, String> params, @NonNull String sql) Returns a list ofStatementInfoWrapper
containing sql statements constructed with the sql statement and the parameters provided
-
Constructor Details
-
StatementUtil
public StatementUtil()
-
-
Method Details
-
isQuery
Returns true if the statement is a query (eg: SELECT, SHOW).- Parameters:
cleanSql
- the clean sql (sql statement without comments)- Returns:
- true if the statement is a query (eg: SELECT, SHOW).
-
extractParamFromSetStatement
public Optional<Map.Entry<String,String>> extractParamFromSetStatement(@NonNull @NonNull String cleanSql, String sql) Extracts parameter from statement (eg: SET x=y)- Parameters:
cleanSql
- the clean version of the sql (sql statement without comments)sql
- the sql statement- Returns:
- an optional parameter represented with a pair of key/value
-
parseToStatementInfoWrappers
Parse the sql statement to a list ofStatementInfoWrapper
- Parameters:
sql
- the sql statement- Returns:
- a list of
StatementInfoWrapper
-
parseToRawStatementWrapper
Parse sql statement to aRawStatementWrapper
. The method construct theRawStatementWrapper
by splitting it in a list of sub-statements (supports multi-statements)- Parameters:
sql
- the sql statement- Returns:
- a list of
StatementInfoWrapper
-
getParamMarketsPositions
Returns the positions of the params markers- Parameters:
sql
- the sql statement- Returns:
- the positions of the params markers
-
extractDbNameAndTableNamePairFromCleanQuery
public Map.Entry<Optional<String>,Optional<String>> extractDbNameAndTableNamePairFromCleanQuery(String cleanSql) Extract the database name and the table name from the cleaned sql query- Parameters:
cleanSql
- the clean sql query- Returns:
- the database name and the table name from the sql query as a pair
-
replaceParameterMarksWithValues
public static List<StatementInfoWrapper> replaceParameterMarksWithValues(@NonNull @NonNull Map<Integer, String> params, @NonNull @NonNull String sql) Returns a list ofStatementInfoWrapper
containing sql statements constructed with the sql statement and the parameters provided- Parameters:
params
- the parameterssql
- the sql statement- Returns:
- a list of sql statements containing the provided parameters
-
replaceParameterMarksWithValues
public List<StatementInfoWrapper> replaceParameterMarksWithValues(@NonNull @NonNull Map<Integer, String> params, @NonNull @NonNull RawStatementWrapper rawStatement) Returns a list ofStatementInfoWrapper
containing sql statements constructed with theRawStatementWrapper
and the parameters provided- Parameters:
params
- the parametersrawStatement
- the rawStatement- Returns:
- a list of sql statements containing the provided parameters
-