Class AbstractStatementParser

  • Direct Known Subclasses:
    PostgreSQLStatementParser, SpannerStatementParser

    @InternalApi
    public abstract class AbstractStatementParser
    extends Object
    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.

    • Method Detail

      • isDdlStatement

        @InternalApi
        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.
        Parameters:
        sql - The statement to check (without any comments).
        Returns:
        true if the statement is a DDL statement (i.e. starts with 'CREATE', 'ALTER' or 'DROP').
      • isQuery

        @InternalApi
        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.
        Parameters:
        sql - The statement to check (without any comments).
        Returns:
        true if the statement is a SELECT statement (i.e. starts with 'SELECT').
      • isUpdateStatement

        @InternalApi
        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.
        Parameters:
        sql - The statement to check (without any comments).
        Returns:
        true if the statement is a DML update statement (i.e. starts with 'INSERT', 'UPDATE' or 'DELETE').
      • supportsExplain

        protected abstract boolean supportsExplain()
      • removeCommentsAndTrim

        @InternalApi
        public String removeCommentsAndTrim​(String sql)