public static class Select.SelectionOrAlias extends Select.Selection
This only differs from Select.Selection
in that you can add an alias for the previously
selected item through as(java.lang.String)
.
Constructor and Description |
---|
SelectionOrAlias() |
Modifier and Type | Method and Description |
---|---|
Select.Builder |
all()
Selects all columns (i.e.
|
Select.Selection |
as(String alias)
Adds an alias for the just selected item.
|
Select.SelectionOrAlias |
avg(Object column)
Creates an
avg(x) built-in function call. |
Select.SelectionOrAlias |
cast(Object column,
DataType targetType)
Creates a cast of an expression to a given CQL type.
|
Select.SelectionOrAlias |
column(String name)
Selects the provided column.
|
Select.SelectionOrAlias |
count(Object column)
Creates a
count(x) built-in function call. |
Select.Builder |
countAll()
Selects the count of all returned rows (i.e.
|
Select.SelectionOrAlias |
fcall(String name,
Object... parameters)
Creates a function call.
|
Select |
from(MaterializedViewMetadata view)
Adds the materialized view to select from.
|
Select |
from(String keyspace,
String table)
Adds the table to select from.
|
Select |
from(TableMetadata table)
Adds the table to select from.
|
Select.SelectionOrAlias |
max(Object column)
Creates a
max(x) built-in function call. |
Select.SelectionOrAlias |
min(Object column)
Creates a
min(x) built-in function call. |
Select.SelectionOrAlias |
path(String... segments)
Selects the provided path.
|
Select.SelectionOrAlias |
raw(String rawString)
Selects the provided raw expression.
|
Select.SelectionOrAlias |
sum(Object column)
Creates a
sum(x) built-in function call. |
Select.SelectionOrAlias |
toJson(String name)
Creates a
toJson() function call. |
Select.SelectionOrAlias |
ttl(String name)
Selects the ttl of provided column.
|
Select.SelectionOrAlias |
writeTime(String name)
Selects the write time of provided column.
|
distinct, json
from
public Select.Selection as(String alias)
alias
- the name of the alias to use.public Select.Builder all()
Select.Selection
all
in class Select.Selection
public Select.Builder countAll()
Select.Selection
countAll
in class Select.Selection
public Select.SelectionOrAlias column(String name)
Select.Selection
column
in class Select.Selection
name
- the new column name to add.public Select.SelectionOrAlias writeTime(String name)
Select.Selection
This is a shortcut for fcall("writetime", QueryBuilder.column(name))
.
writeTime
in class Select.Selection
name
- the name of the column to select the write time of.public Select.SelectionOrAlias ttl(String name)
Select.Selection
This is a shortcut for fcall("ttl", QueryBuilder.column(name))
.
ttl
in class Select.Selection
name
- the name of the column to select the ttl of.public Select.SelectionOrAlias fcall(String name, Object... parameters)
Select.Selection
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 the QueryBuilder.column(java.lang.String)
method, and
so fcall("textToBlob", QueryBuilder.column(foo)
.
fcall
in class Select.Selection
name
- the name of the function.parameters
- the parameters for the function call.public Select.SelectionOrAlias cast(Object column, DataType targetType)
Select.Selection
cast
in class Select.Selection
column
- the expression to cast. It can be a complex expression like a function call
.targetType
- the target CQL type to cast to. Use static methods such as DataType.text()
.public Select.SelectionOrAlias raw(String rawString)
Select.Selection
The provided string will be appended to the query as-is, without any form of escaping or quoting.
raw
in class Select.Selection
rawString
- the raw expression to add.public Select.SelectionOrAlias path(String... segments)
Select.Selection
All given path segments
will be concatenated together with dots. If any segment
contains an identifier that needs quoting, caller code is expected to call QueryBuilder.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
.
path
in class Select.Selection
segments
- the segments of the path to create.public Select.SelectionOrAlias toJson(String name)
Select.Selection
toJson()
function call. This is a shortcut for fcall("toJson",
QueryBuilder.column(name))
.
Support for JSON functions has been added in Cassandra 2.2. The toJson()
function
is similar to SELECT JSON
statements, 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 SELECT
statement.
toJson
in class Select.Selection
name
- the column to retrieve JSON from.public Select.SelectionOrAlias count(Object column)
Select.Selection
count(x)
built-in function call.count
in class Select.Selection
public Select.SelectionOrAlias max(Object column)
Select.Selection
max(x)
built-in function call.max
in class Select.Selection
public Select.SelectionOrAlias min(Object column)
Select.Selection
min(x)
built-in function call.min
in class Select.Selection
public Select.SelectionOrAlias sum(Object column)
Select.Selection
sum(x)
built-in function call.sum
in class Select.Selection
public Select.SelectionOrAlias avg(Object column)
Select.Selection
avg(x)
built-in function call.avg
in class Select.Selection
public Select from(String keyspace, String table)
Select.Builder
from
in class Select.Builder
keyspace
- the name of the keyspace to select from.table
- the name of the table to select from.keyspace.table
.public Select from(TableMetadata table)
Select.Builder
from
in class Select.Builder
table
- the table to select from.table
.public Select from(MaterializedViewMetadata view)
Select.Builder
from
in class Select.Builder
view
- the materialized view to select from.view
.Copyright © 2012–2024. All rights reserved.