Class Select.SelectionOrAlias
- java.lang.Object
-
- com.datastax.driver.core.querybuilder.Select.Builder
-
- com.datastax.driver.core.querybuilder.Select.Selection
-
- com.datastax.driver.core.querybuilder.Select.SelectionOrAlias
-
- Enclosing class:
- Select
public static class Select.SelectionOrAlias extends Select.Selection
An Selection clause for an in-construction SELECT statement.This only differs from
Select.Selectionin that you can add an alias for the previously selected item throughas(java.lang.String).
-
-
Constructor Summary
Constructors Constructor Description SelectionOrAlias()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Select.Builderall()Selects all columns (i.e.Select.Selectionas(String alias)Adds an alias for the just selected item.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.Select.SelectionOrAliascolumn(String name)Selects the provided column.Select.SelectionOrAliascount(Object column)Creates acount(x)built-in function call.Select.BuildercountAll()Selects the count of all returned rows (i.e.Select.SelectionOrAliasfcall(String name, Object... parameters)Creates a function call.Selectfrom(MaterializedViewMetadata view)Adds the materialized view to select from.Selectfrom(TableMetadata table)Adds the table to select from.Selectfrom(String keyspace, String table)Adds the table to select from.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 name)Creates atoJson()function call.Select.SelectionOrAliasttl(String name)Selects the ttl of provided column.Select.SelectionOrAliaswriteTime(String name)Selects the write time of provided column.-
Methods inherited from class com.datastax.driver.core.querybuilder.Select.Selection
distinct, json
-
Methods inherited from class com.datastax.driver.core.querybuilder.Select.Builder
from
-
-
-
-
Method Detail
-
as
public Select.Selection as(String alias)
Adds an alias for the just selected item.- Parameters:
alias- the name of the alias to use.- Returns:
- this in-build SELECT statement
-
all
public Select.Builder all()
Description copied from class:Select.SelectionSelects all columns (i.e. "SELECT * ...")- Specified by:
allin classSelect.Selection- Returns:
- an in-build SELECT statement.
-
countAll
public Select.Builder countAll()
Description copied from class:Select.SelectionSelects the count of all returned rows (i.e. "SELECT count(*) ...").- Specified by:
countAllin classSelect.Selection- Returns:
- an in-build SELECT statement.
-
column
public Select.SelectionOrAlias column(String name)
Description copied from class:Select.SelectionSelects the provided column.- Specified by:
columnin classSelect.Selection- Parameters:
name- the new column name to add.- Returns:
- this in-build SELECT statement
-
writeTime
public Select.SelectionOrAlias writeTime(String name)
Description copied from class:Select.SelectionSelects the write time of provided column.This is a shortcut for
fcall("writetime", QueryBuilder.column(name)).- Specified by:
writeTimein classSelect.Selection- Parameters:
name- the name of the column to select the write time of.- Returns:
- this in-build SELECT statement
-
ttl
public Select.SelectionOrAlias ttl(String name)
Description copied from class:Select.SelectionSelects the ttl of provided column.This is a shortcut for
fcall("ttl", QueryBuilder.column(name)).- Specified by:
ttlin classSelect.Selection- Parameters:
name- the name of the column to select the ttl of.- Returns:
- this in-build SELECT statement
-
fcall
public Select.SelectionOrAlias fcall(String name, Object... parameters)
Description copied from class:Select.SelectionCreates 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).- Specified by:
fcallin classSelect.Selection- 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)
Description copied from class:Select.SelectionCreates a cast of an expression to a given CQL type.- Overrides:
castin classSelect.Selection- 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)
Description copied from class:Select.SelectionSelects the provided raw expression.The provided string will be appended to the query as-is, without any form of escaping or quoting.
- Overrides:
rawin classSelect.Selection- Parameters:
rawString- the raw expression to add.- Returns:
- this in-build SELECT statement
-
path
public Select.SelectionOrAlias path(String... segments)
Description copied from class:Select.SelectionSelects 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.- Overrides:
pathin classSelect.Selection- 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 name)
Description copied from class:Select.SelectionCreates 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.- Overrides:
toJsonin classSelect.Selection- Parameters:
name- 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)
Description copied from class:Select.SelectionCreates acount(x)built-in function call.- Overrides:
countin classSelect.Selection- Returns:
- the function call.
-
max
public Select.SelectionOrAlias max(Object column)
Description copied from class:Select.SelectionCreates amax(x)built-in function call.- Overrides:
maxin classSelect.Selection- Returns:
- the function call.
-
min
public Select.SelectionOrAlias min(Object column)
Description copied from class:Select.SelectionCreates amin(x)built-in function call.- Overrides:
minin classSelect.Selection- Returns:
- the function call.
-
sum
public Select.SelectionOrAlias sum(Object column)
Description copied from class:Select.SelectionCreates asum(x)built-in function call.- Overrides:
sumin classSelect.Selection- Returns:
- the function call.
-
avg
public Select.SelectionOrAlias avg(Object column)
Description copied from class:Select.SelectionCreates anavg(x)built-in function call.- Overrides:
avgin classSelect.Selection- Returns:
- the function call.
-
from
public Select from(String keyspace, String table)
Description copied from class:Select.BuilderAdds the table to select from.- Overrides:
fromin classSelect.Builder- Parameters:
keyspace- the name of the keyspace to select from.table- the name of the table to select from.- Returns:
- a newly built SELECT statement that selects from
keyspace.table.
-
from
public Select from(TableMetadata table)
Description copied from class:Select.BuilderAdds the table to select from.- Overrides:
fromin classSelect.Builder- Parameters:
table- the table to select from.- Returns:
- a newly built SELECT statement that selects from
table.
-
from
public Select from(MaterializedViewMetadata view)
Description copied from class:Select.BuilderAdds the materialized view to select from.- Overrides:
fromin classSelect.Builder- Parameters:
view- the materialized view to select from.- Returns:
- a newly built SELECT statement that selects from
view.
-
-