Class Statement (2.51.0)

public class Statement

A SQL statement that can be executed by calling com.google.cloud.bigtable.data.v2.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 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();
 

Inheritance

java.lang.Object > Statement

Static Methods

newBuilder(String sql)

public static Statement.Builder newBuilder(String sql)

Creates a new Builder with the given SQL query

Parameter
Name Description
sql String
Returns
Type Description
Statement.Builder

of(String sql)

public static Statement of(String sql)

Creates a Statement with the given SQL query and no query parameters.

Parameter
Name Description
sql String
Returns
Type Description
Statement

Methods

toProto(RequestContext requestContext)

public ExecuteQueryRequest toProto(RequestContext requestContext)

Creates the request protobuf. This method is considered an internal implementation detail and not meant to be used by applications.

Parameter
Name Description
requestContext com.google.cloud.bigtable.data.v2.internal.RequestContext
Returns
Type Description
com.google.bigtable.v2.ExecuteQueryRequest