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

create_field(name, opts)
field(name)

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.

field(name, opts)

Specs

field(t, atom) :: t
field(s, name, opts)
from(s, database_name, series_name)

Specs

from(t, String.t, String.t) :: t

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.

function(name, args, list)

Specs

function(String.t, [any], Keyword.t) :: (... -> any)
function(s, name, args, list)

Specs

function(t, String.t, [any], Keyword.t) :: t

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.

group_by(s, count, unit \\ :usecs)

Groups the results by an interval.

Params: - count - number of units to aggregate over. - unit - unit to aggregate over.

Example:

group_by(13, :mins)
interpolate_with(s, method)

Specs

interpolate_with(t, atom) :: t

Specifies the interpolation to be used to generate the result when there are holes in the data.

select()

Specs

select :: t

Creates an empty select statement.

tag(name)

Specs

tag(atom | String.t) :: tag

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.

tag(name, opts)

Specs

tag(atom | String.t, Keyword.t) :: tag
tag(t, atom | String.t) :: t
tag(s, name, opts)

Specs

tag(t, atom | String.t, Keyword.t) :: t
where(s, field, operator, value)

Specs

where(t, field | function | tag, op, any) :: t

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 :!=)