public class AggregateGroupByRequest extends Object implements org.apache.avro.generic.IndexedRecord
GPUdb.aggregateGroupByRaw(AggregateGroupByRequest)
.
Calculates unique combinations (groups) of values for the given columns in a given table/view/collection and computes aggregates on each unique combination. This is somewhat analogous to an SQL-style SELECT...GROUP BY.
Any column(s) can be grouped on, and all column types except unrestricted-length strings may be used for computing applicable aggregates; columns marked as store-only are unable to be used in grouping or aggregation.
The results can be paged via the offset
and limit
parameters. For example, to get 10 groups with the largest counts the inputs
would be: limit=10, options={"sort_order":"descending", "sort_by":"value"}.
options
can be used to customize behavior of this call e.g.
filtering or sorting the results.
To group by columns 'x' and 'y' and compute the number of objects within each group, use: column_names=['x','y','count(*)'].
To also compute the sum of 'z' over each group, use: column_names=['x','y','count(*)','sum(z)'].
Available aggregation functions are: count(*), sum, min, max, avg, mean, stddev, stddev_pop, stddev_samp, var, var_pop, var_samp, arg_min, arg_max and count_distinct.
The response is returned as a dynamic schema. For details see: dynamic schemas documentation.
If a result_table
name is specified in the options
, the
results are stored in a new table with that name--no results are returned in
the response. Both the table name and resulting column names must adhere to
standard
naming conventions; column/aggregation expressions will need to be
aliased. If the source table's shard
key is used as the grouping column(s), the result table will be sharded,
in all other cases it will be replicated. Sorting will properly function
only if the result table is replicated or if there is only one processing
node and should not be relied upon in other cases. Not available when any
of the values of columnNames
is an unrestricted-length string.
Modifier and Type | Class and Description |
---|---|
static class |
AggregateGroupByRequest.Encoding
Specifies the encoding for returned records.
|
static class |
AggregateGroupByRequest.Options
Optional parameters.
|
Constructor and Description |
---|
AggregateGroupByRequest()
Constructs an AggregateGroupByRequest object with default parameters.
|
AggregateGroupByRequest(String tableName,
List<String> columnNames,
long offset,
long limit,
Map<String,String> options)
Constructs an AggregateGroupByRequest object with the specified
parameters.
|
AggregateGroupByRequest(String tableName,
List<String> columnNames,
long offset,
long limit,
String encoding,
Map<String,String> options)
Constructs an AggregateGroupByRequest object with the specified
parameters.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
Object |
get(int index)
This method supports the Avro framework and is not intended to be called
directly by the user.
|
static org.apache.avro.Schema |
getClassSchema()
This method supports the Avro framework and is not intended to be called
directly by the user.
|
List<String> |
getColumnNames() |
String |
getEncoding() |
long |
getLimit() |
long |
getOffset() |
Map<String,String> |
getOptions() |
org.apache.avro.Schema |
getSchema()
This method supports the Avro framework and is not intended to be called
directly by the user.
|
String |
getTableName() |
int |
hashCode() |
void |
put(int index,
Object value)
This method supports the Avro framework and is not intended to be called
directly by the user.
|
AggregateGroupByRequest |
setColumnNames(List<String> columnNames) |
AggregateGroupByRequest |
setEncoding(String encoding) |
AggregateGroupByRequest |
setLimit(long limit) |
AggregateGroupByRequest |
setOffset(long offset) |
AggregateGroupByRequest |
setOptions(Map<String,String> options) |
AggregateGroupByRequest |
setTableName(String tableName) |
String |
toString() |
public AggregateGroupByRequest()
public AggregateGroupByRequest(String tableName, List<String> columnNames, long offset, long limit, Map<String,String> options)
tableName
- Name of the table on which the operation will be
performed. Must be an existing table/view/collection.columnNames
- List of one or more column names, expressions, and
aggregate expressions. Must include at least one
'grouping' column or expression. If no aggregate is
included, count(*) will be computed as a default.offset
- A positive integer indicating the number of initial
results to skip (this can be useful for paging through
the results). The minimum allowed value is 0. The
maximum allowed value is MAX_INT.limit
- A positive integer indicating the maximum number of
results to be returned Or END_OF_SET (-9999) to indicate
that the max number of results should be returned.options
- Optional parameters.
COLLECTION_NAME
: Name of a collection which is to
contain the table specified in result_table
,
otherwise the table will be a top-level table. If the
collection does not allow duplicate types and it
contains a table of the same type as the given one, then
this table creation request will fail. Additionally this
option is invalid if tableName
is a collection.
EXPRESSION
: Filter expression to apply to the table
prior to computing the aggregate group by.
HAVING
: Filter expression to apply to the aggregated
results.
SORT_ORDER
: String indicating how the returned values
should be sorted - ascending or descending.
Supported values:
ASCENDING
: Indicates that the returned values should be
sorted in ascending order.
DESCENDING
: Indicates that the returned values should
be sorted in descending order.
ASCENDING
.
SORT_BY
: String determining how the results are sorted.
Supported values:
KEY
: Indicates that the returned values should be
sorted by key, which corresponds to the grouping
columns. If you have multiple grouping columns (and are
sorting by key), it will first sort the first grouping
column, then the second grouping column, etc.
VALUE
: Indicates that the returned values should be
sorted by value, which corresponds to the aggregates. If
you have multiple aggregates (and are sorting by value),
it will first sort by the first aggregate, then the
second aggregate, etc.
KEY
.
RESULT_TABLE
: The name of the table used to store the
results. Has the same naming restrictions as tables. Column names (group-by and
aggregate fields) need to be given aliases e.g.
["FChar256 as fchar256", "sum(FDouble) as sfd"]. If
present, no results are returned in the response. This
option is not available if one of the grouping
attributes is an unrestricted string (i.e.; not charN)
type.
RESULT_TABLE_PERSIST
: If true
then the result
table specified in result_table
will be
persisted as a regular table (it will not be
automatically cleared unless a ttl
is provided,
and the table data can be modified in subsequent
operations). If false
then the result table will
be a read-only, memory-only temporary table.
Supported values:
The default value is FALSE
.
TTL
: Sets the TTL of the table specified in result_table
. The value must be the desired TTL in
minutes.
public AggregateGroupByRequest(String tableName, List<String> columnNames, long offset, long limit, String encoding, Map<String,String> options)
tableName
- Name of the table on which the operation will be
performed. Must be an existing table/view/collection.columnNames
- List of one or more column names, expressions, and
aggregate expressions. Must include at least one
'grouping' column or expression. If no aggregate is
included, count(*) will be computed as a default.offset
- A positive integer indicating the number of initial
results to skip (this can be useful for paging through
the results). The minimum allowed value is 0. The
maximum allowed value is MAX_INT.limit
- A positive integer indicating the maximum number of
results to be returned Or END_OF_SET (-9999) to indicate
that the max number of results should be returned.encoding
- Specifies the encoding for returned records.
Supported values:
BINARY
: Indicates that the returned records should be
binary encoded.
JSON
: Indicates that the returned records should be
json encoded.
BINARY
.options
- Optional parameters.
COLLECTION_NAME
: Name of a collection which is to
contain the table specified in result_table
,
otherwise the table will be a top-level table. If the
collection does not allow duplicate types and it
contains a table of the same type as the given one, then
this table creation request will fail. Additionally this
option is invalid if tableName
is a collection.
EXPRESSION
: Filter expression to apply to the table
prior to computing the aggregate group by.
HAVING
: Filter expression to apply to the aggregated
results.
SORT_ORDER
: String indicating how the returned values
should be sorted - ascending or descending.
Supported values:
ASCENDING
: Indicates that the returned values should be
sorted in ascending order.
DESCENDING
: Indicates that the returned values should
be sorted in descending order.
ASCENDING
.
SORT_BY
: String determining how the results are sorted.
Supported values:
KEY
: Indicates that the returned values should be
sorted by key, which corresponds to the grouping
columns. If you have multiple grouping columns (and are
sorting by key), it will first sort the first grouping
column, then the second grouping column, etc.
VALUE
: Indicates that the returned values should be
sorted by value, which corresponds to the aggregates. If
you have multiple aggregates (and are sorting by value),
it will first sort by the first aggregate, then the
second aggregate, etc.
KEY
.
RESULT_TABLE
: The name of the table used to store the
results. Has the same naming restrictions as tables. Column names (group-by and
aggregate fields) need to be given aliases e.g.
["FChar256 as fchar256", "sum(FDouble) as sfd"]. If
present, no results are returned in the response. This
option is not available if one of the grouping
attributes is an unrestricted string (i.e.; not charN)
type.
RESULT_TABLE_PERSIST
: If true
then the result
table specified in result_table
will be
persisted as a regular table (it will not be
automatically cleared unless a ttl
is provided,
and the table data can be modified in subsequent
operations). If false
then the result table will
be a read-only, memory-only temporary table.
Supported values:
The default value is FALSE
.
TTL
: Sets the TTL of the table specified in result_table
. The value must be the desired TTL in
minutes.
public static org.apache.avro.Schema getClassSchema()
public String getTableName()
public AggregateGroupByRequest setTableName(String tableName)
tableName
- Name of the table on which the operation will be
performed. Must be an existing table/view/collection.this
to mimic the builder pattern.public List<String> getColumnNames()
public AggregateGroupByRequest setColumnNames(List<String> columnNames)
columnNames
- List of one or more column names, expressions, and
aggregate expressions. Must include at least one
'grouping' column or expression. If no aggregate is
included, count(*) will be computed as a default.this
to mimic the builder pattern.public long getOffset()
public AggregateGroupByRequest setOffset(long offset)
offset
- A positive integer indicating the number of initial
results to skip (this can be useful for paging through
the results). The minimum allowed value is 0. The
maximum allowed value is MAX_INT.this
to mimic the builder pattern.public long getLimit()
public AggregateGroupByRequest setLimit(long limit)
limit
- A positive integer indicating the maximum number of
results to be returned Or END_OF_SET (-9999) to indicate
that the max number of results should be returned.this
to mimic the builder pattern.public String getEncoding()
public AggregateGroupByRequest setEncoding(String encoding)
public Map<String,String> getOptions()
COLLECTION_NAME
: Name of a collection which is to contain the
table specified in result_table
, otherwise the table
will be a top-level table. If the collection does not allow
duplicate types and it contains a table of the same type as the
given one, then this table creation request will fail.
Additionally this option is invalid if tableName
is a
collection.
EXPRESSION
: Filter expression to apply to the table prior to
computing the aggregate group by.
HAVING
: Filter expression to apply to the aggregated results.
SORT_ORDER
: String indicating how the returned values should be
sorted - ascending or descending.
Supported values:
ASCENDING
: Indicates that the returned values should be sorted
in ascending order.
DESCENDING
: Indicates that the returned values should be sorted
in descending order.
ASCENDING
.
SORT_BY
: String determining how the results are sorted.
Supported values:
KEY
:
Indicates that the returned values should be sorted by key,
which corresponds to the grouping columns. If you have multiple
grouping columns (and are sorting by key), it will first sort
the first grouping column, then the second grouping column, etc.
VALUE
:
Indicates that the returned values should be sorted by value,
which corresponds to the aggregates. If you have multiple
aggregates (and are sorting by value), it will first sort by the
first aggregate, then the second aggregate, etc.
KEY
.
RESULT_TABLE
: The name of the table used to store the results.
Has the same naming restrictions as tables. Column names (group-by and aggregate
fields) need to be given aliases e.g. ["FChar256 as fchar256",
"sum(FDouble) as sfd"]. If present, no results are returned in
the response. This option is not available if one of the
grouping attributes is an unrestricted string (i.e.; not charN)
type.
RESULT_TABLE_PERSIST
: If true
then the result table
specified in result_table
will be persisted as a regular
table (it will not be automatically cleared unless a ttl
is provided, and the table data can be modified in subsequent
operations). If false
then the result table will be a
read-only, memory-only temporary table.
Supported values:
The default value is FALSE
.
TTL
:
Sets the TTL of the table specified in result_table
. The
value must be the desired TTL in minutes.
public AggregateGroupByRequest setOptions(Map<String,String> options)
options
- Optional parameters.
COLLECTION_NAME
: Name of a collection which is to
contain the table specified in result_table
,
otherwise the table will be a top-level table. If the
collection does not allow duplicate types and it
contains a table of the same type as the given one, then
this table creation request will fail. Additionally this
option is invalid if tableName
is a collection.
EXPRESSION
: Filter expression to apply to the table
prior to computing the aggregate group by.
HAVING
: Filter expression to apply to the aggregated
results.
SORT_ORDER
: String indicating how the returned values
should be sorted - ascending or descending.
Supported values:
ASCENDING
: Indicates that the returned values should be
sorted in ascending order.
DESCENDING
: Indicates that the returned values should
be sorted in descending order.
ASCENDING
.
SORT_BY
: String determining how the results are sorted.
Supported values:
KEY
: Indicates that the returned values should be
sorted by key, which corresponds to the grouping
columns. If you have multiple grouping columns (and are
sorting by key), it will first sort the first grouping
column, then the second grouping column, etc.
VALUE
: Indicates that the returned values should be
sorted by value, which corresponds to the aggregates. If
you have multiple aggregates (and are sorting by value),
it will first sort by the first aggregate, then the
second aggregate, etc.
KEY
.
RESULT_TABLE
: The name of the table used to store the
results. Has the same naming restrictions as tables. Column names (group-by and
aggregate fields) need to be given aliases e.g.
["FChar256 as fchar256", "sum(FDouble) as sfd"]. If
present, no results are returned in the response. This
option is not available if one of the grouping
attributes is an unrestricted string (i.e.; not charN)
type.
RESULT_TABLE_PERSIST
: If true
then the result
table specified in result_table
will be
persisted as a regular table (it will not be
automatically cleared unless a ttl
is provided,
and the table data can be modified in subsequent
operations). If false
then the result table will
be a read-only, memory-only temporary table.
Supported values:
The default value is FALSE
.
TTL
: Sets the TTL of the table specified in result_table
. The value must be the desired TTL in
minutes.
this
to mimic the builder pattern.public org.apache.avro.Schema getSchema()
getSchema
in interface org.apache.avro.generic.GenericContainer
public Object get(int index)
get
in interface org.apache.avro.generic.IndexedRecord
index
- the position of the field to getIndexOutOfBoundsException
public void put(int index, Object value)
put
in interface org.apache.avro.generic.IndexedRecord
index
- the position of the field to setvalue
- the value to setIndexOutOfBoundsException
Copyright © 2017. All rights reserved.