public abstract class AbstractStatementParser
Internal class for the Spanner Connection API.
Parses ClientSideStatements and normal SQL statements. The parser is able to recognize the type of statement, allowing the connection API to know which method on Spanner should be called. The parser does not validate the validity of statements, except for ClientSideStatements. This means that an invalid DML statement could be accepted by the AbstractStatementParser and sent to Spanner, and Spanner will then reject it with some error message.
Static Methods
getInstance(Dialect dialect)
public static AbstractStatementParser getInstance(Dialect dialect)
Get an instance of AbstractStatementParser for the specified dialect.
Parameter | |
---|---|
Name | Description |
dialect | Dialect |
Returns | |
---|---|
Type | Description |
AbstractStatementParser |
Methods
convertPositionalParametersToNamedParameters(char paramChar, String sql)
public AbstractStatementParser.ParametersInfo convertPositionalParametersToNamedParameters(char paramChar, String sql)
Parameters | |
---|---|
Name | Description |
paramChar | char |
sql | String |
Returns | |
---|---|
Type | Description |
AbstractStatementParser.ParametersInfo |
isDdlStatement(String sql)
public boolean isDdlStatement(String sql)
Checks whether the given statement is (probably) a DDL statement. The method does not check the validity of the statement, only if it is a DDL statement based on the first word in the statement.
Parameter | |
---|---|
Name | Description |
sql | String The statement to check (without any comments). |
Returns | |
---|---|
Type | Description |
boolean |
|
isQuery(String sql)
public boolean isQuery(String sql)
Checks whether the given statement is (probably) a SELECT query. The method does not check the validity of the statement, only if it is a SELECT statement based on the first word in the statement.
Parameter | |
---|---|
Name | Description |
sql | String The statement to check (without any comments). |
Returns | |
---|---|
Type | Description |
boolean |
|
isUpdateStatement(String sql)
public boolean isUpdateStatement(String sql)
Checks whether the given statement is (probably) an update statement. The method does not check the validity of the statement, only if it is an update statement based on the first word in the statement.
Parameter | |
---|---|
Name | Description |
sql | String The statement to check (without any comments). |
Returns | |
---|---|
Type | Description |
boolean |
|
parse(Statement statement)
public AbstractStatementParser.ParsedStatement parse(Statement statement)
Parses the given statement and categorizes it as one of the possible StatementTypes. The validity of the statement is not checked, unless it is a client-side statement.
Parameter | |
---|---|
Name | Description |
statement | Statement The statement to parse. |
Returns | |
---|---|
Type | Description |
AbstractStatementParser.ParsedStatement | the parsed and categorized statement. |
removeCommentsAndTrim(String sql)
public String removeCommentsAndTrim(String sql)
Parameter | |
---|---|
Name | Description |
sql | String |
Returns | |
---|---|
Type | Description |
String |
supportsExplain()
protected abstract boolean supportsExplain()
Returns | |
---|---|
Type | Description |
boolean |