java.lang.Object
com.google.cloud.bigtable.data.v2.models.sql.Statement

@BetaApi public class Statement extends Object
A SQL statement that can be executed by calling BigtableDataClient.executeQuery(Statement).

A statement contains a SQL string and optional parameters. A parameterized query should contain placeholders in the form of @ followed by the parameter name. Parameter names may consist of any combination of letters, numbers, and underscores.

Parameters can appear anywhere that a literal value is expected. The same parameter name can be used more than once, for example: WHERE cf["qualifier1"] = @value OR cf["qualifier2"] = @value

It is an error to execute an SQL query with placeholders for unset parameters.

Parameterized Statements are constructed using a Statement.Builder and calling setTypeParam(String paramName, Type value) for the appropriate type. For example:


 Statement statement = Statement
     .newBuilder("SELECT cf[@qualifer] FROM table WHERE _key=@key")
     .setBytesParam("qualifier", ByteString.copyFromUtf8("test"))
     .setBytesParam("key", ByteString.copyFromUtf8("testKey"))
     .build();
 
  • Method Details

    • of

      public static Statement of(String sql)
      Creates a Statement with the given SQL query and no query parameters.
    • newBuilder

      public static Statement.Builder newBuilder(String sql)
      Creates a new Builder with the given SQL query
    • toProto

      @InternalApi("For internal use only") public ExecuteQueryRequest toProto(com.google.cloud.bigtable.data.v2.internal.RequestContext requestContext)
      Creates the request protobuf. This method is considered an internal implementation detail and not meant to be used by applications.