phasedb v0.0.2 PhaseDB.Select
Describes a select operation from a series as an abstract representation.
Select is a struct, but please do not manipulate the fields directly as it's structure may be subject to change.
Example:
use Calendar
import PhaseDB.Select
alias PhaseDB.Query
select
|> field(:value)
|> from("database_name", "series_name")
|> where(field(:value), :>, 13)
|> Query.execute
select
|> function(:count, [field(:value)], as: :value)
|> from("database_name", "series_name")
|> where(field(:value), :>, 13)
|> group_by(1, :secs)
|> interpolate_with(:nearest_neighbour)
|> Query.execute
select
|> tag(:city)
|> from("database_name", "series_name")
|> Query.execute
select
|> function(:uniq, [tag(:city)], as: :unique_cities)
|> from("database_name", "series_name")
Summary
Functions
Adds a field value to the list of fields to return from the query
Adds the query target to the query
Adds a function call to the list of fields to return from the query
Groups the results by an interval
Specifies the interpolation to be used to generate the result when there are holes in the data
Creates an empty select statement
Adds a tag value to the list of fields to return from the query
Adds a where clause to the query
Types
field :: %PhaseDB.Select.Field{as: term, name: term}
fun :: %PhaseDB.Select.Function{arguments: term, as: term, name: term}
op :: :< | :<= | :> | :>= | :== | :!=
t :: %PhaseDB.Select{fields: term, from: term, group_by: term, interpolation: term, wheres: term}
tag :: %PhaseDB.Select.Tag{as: term, name: term}
where :: %PhaseDB.Select.Where{lhs: term, operator: term, rhs: term}
Functions
Specs
field(atom) :: field
Adds a field value to the list of fields to return from the query.
Params: - select
- optional. an existing select query, created by select
. - name
- the name of the field to retrieve. - as:
- optional, the name of the field to in the output. defaults to the field name.
Adds the query target to the query.
Params: - select
- an existing select query, created by select
. - database_name
- the name of a database. - series_name
- the name of a series.
Adds a function call to the list of fields to return from the query.
Params: - select
- optional. an existing select query, created by select
. - name
- the name of the function to apply, see PhaseDB.Functions
for a complete list. - args
- a list of arguments to pass to the function. Usually a field as a bare minimum. - as:
- the name of the field to output.
Groups the results by an interval.
Params: - count
- number of units to aggregate over. - unit
- unit to aggregate over.
Example:
group_by(13, :mins)
Specifies the interpolation to be used to generate the result when there are holes in the data.
Adds a tag value to the list of fields to return from the query.
Params: - select
- optional. an existing select query, created by select
. - name
- the name of the tag to retrieve. - as:
- optional, the name of the field to in the output. defaults to the tag name.
Adds a where clause to the query.
Params: - select
- an existing select query, created by select
. - field
- the output of either field
, function
or tag
. - operator
- a comparison operator (:<
, :<=
, :>
, :>=
, :==
or :!=
)