Class Select.Selection
- java.lang.Object
-
- com.datastax.driver.core.querybuilder.Select.Builder
-
- com.datastax.driver.core.querybuilder.Select.Selection
-
- Direct Known Subclasses:
Select.SelectionOrAlias
- Enclosing class:
- Select
public abstract static class Select.Selection extends Select.Builder
An Selection clause for an in-construction SELECT statement.
-
-
Constructor Summary
Constructors Constructor Description Selection()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Select.Builderall()Selects all columns (i.e.Select.SelectionOrAliasavg(Object column)Creates anavg(x)built-in function call.Select.SelectionOrAliascast(Object column, DataType targetType)Creates a cast of an expression to a given CQL type.abstract Select.SelectionOrAliascolumn(String name)Selects the provided column.Select.SelectionOrAliascount(Object column)Creates acount(x)built-in function call.abstract Select.BuildercountAll()Selects the count of all returned rows (i.e.Select.Selectiondistinct()Uses DISTINCT selection.abstract Select.SelectionOrAliasfcall(String name, Object... parameters)Creates a function call.Select.Selectionjson()Uses JSON selection.Select.SelectionOrAliasmax(Object column)Creates amax(x)built-in function call.Select.SelectionOrAliasmin(Object column)Creates amin(x)built-in function call.Select.SelectionOrAliaspath(String... segments)Selects the provided path.Select.SelectionOrAliasraw(String rawString)Selects the provided raw expression.Select.SelectionOrAliassum(Object column)Creates asum(x)built-in function call.Select.SelectionOrAliastoJson(String column)Creates atoJson()function call.abstract Select.SelectionOrAliasttl(String name)Selects the ttl of provided column.abstract Select.SelectionOrAliaswriteTime(String name)Selects the write time of provided column.-
Methods inherited from class com.datastax.driver.core.querybuilder.Select.Builder
from, from, from, from
-
-
-
-
Method Detail
-
distinct
public Select.Selection distinct()
Uses DISTINCT selection.- Overrides:
distinctin classSelect.Builder- Returns:
- this in-build SELECT statement.
-
json
public Select.Selection json()
Uses JSON selection.Cassandra 2.2 introduced JSON support to SELECT statements: the
JSONkeyword can be used to return each row as a single JSON encoded map.- Overrides:
jsonin classSelect.Builder- Returns:
- this in-build SELECT statement.
- See Also:
- JSON Support for CQL, JSON Support in Cassandra 2.2, Data retrieval using JSON
-
all
public abstract Select.Builder all()
Selects all columns (i.e. "SELECT * ...")- Returns:
- an in-build SELECT statement.
- Throws:
IllegalStateException- if some columns had already been selected for this builder.
-
countAll
public abstract Select.Builder countAll()
Selects the count of all returned rows (i.e. "SELECT count(*) ...").- Returns:
- an in-build SELECT statement.
- Throws:
IllegalStateException- if some columns had already been selected for this builder.
-
column
public abstract Select.SelectionOrAlias column(String name)
Selects the provided column.- Parameters:
name- the new column name to add.- Returns:
- this in-build SELECT statement
-
writeTime
public abstract Select.SelectionOrAlias writeTime(String name)
Selects the write time of provided column.This is a shortcut for
fcall("writetime", QueryBuilder.column(name)).- Parameters:
name- the name of the column to select the write time of.- Returns:
- this in-build SELECT statement
-
ttl
public abstract Select.SelectionOrAlias ttl(String name)
Selects the ttl of provided column.This is a shortcut for
fcall("ttl", QueryBuilder.column(name)).- Parameters:
name- the name of the column to select the ttl of.- Returns:
- this in-build SELECT statement
-
fcall
public abstract Select.SelectionOrAlias fcall(String name, Object... parameters)
Creates a function call.Please note that the parameters are interpreted as values, and so
fcall("textToBlob", "foo")will generate the string"textToBlob('foo')". If you want to generate"textToBlob(foo)", i.e. if the argument must be interpreted as a column name (in a select clause), you will need to use theQueryBuilder.column(java.lang.String)method, and sofcall("textToBlob", QueryBuilder.column(foo).- Parameters:
name- the name of the function.parameters- the parameters for the function call.- Returns:
- this in-build SELECT statement
-
cast
public Select.SelectionOrAlias cast(Object column, DataType targetType)
Creates a cast of an expression to a given CQL type.- Parameters:
column- the expression to cast. It can be a complex expression like afunction call.targetType- the target CQL type to cast to. Use static methods such asDataType.text().- Returns:
- this in-build SELECT statement.
-
raw
public Select.SelectionOrAlias raw(String rawString)
Selects the provided raw expression.The provided string will be appended to the query as-is, without any form of escaping or quoting.
- Parameters:
rawString- the raw expression to add.- Returns:
- this in-build SELECT statement
-
path
public Select.SelectionOrAlias path(String... segments)
Selects the provided path.All given path
segmentswill be concatenated together with dots. If any segment contains an identifier that needs quoting, caller code is expected to callQueryBuilder.quote(String)prior to invoking this method.This method is currently only useful when accessing individual fields of a
user-defined type(UDT), which is only possible since CASSANDRA-7423.Note that currently nested UDT fields are not supported and will be rejected by the server as a
syntax error.- Parameters:
segments- the segments of the path to create.- Returns:
- this in-build SELECT statement
- See Also:
- CASSANDRA-7423
-
toJson
public Select.SelectionOrAlias toJson(String column)
Creates atoJson()function call. This is a shortcut forfcall("toJson", QueryBuilder.column(name)).Support for JSON functions has been added in Cassandra 2.2. The
toJson()function is similar toSELECT JSONstatements, but applies to a single column value instead of the entire row, and produces a JSON-encoded string representing the normal Cassandra column value.It may only be used in the selection clause of a
SELECTstatement.- Parameters:
column- the column to retrieve JSON from.- Returns:
- the function call.
- See Also:
- JSON Support for CQL, JSON Support in Cassandra 2.2
-
count
public Select.SelectionOrAlias count(Object column)
Creates acount(x)built-in function call.- Returns:
- the function call.
-
max
public Select.SelectionOrAlias max(Object column)
Creates amax(x)built-in function call.- Returns:
- the function call.
-
min
public Select.SelectionOrAlias min(Object column)
Creates amin(x)built-in function call.- Returns:
- the function call.
-
sum
public Select.SelectionOrAlias sum(Object column)
Creates asum(x)built-in function call.- Returns:
- the function call.
-
avg
public Select.SelectionOrAlias avg(Object column)
Creates anavg(x)built-in function call.- Returns:
- the function call.
-
-