Ecto.Query.Timescaledb (ecto_timescaledb v0.10.0)

Provides functions in TimescaleDB extended SQL for Ecto.Query

Link to this section Summary

Link to this section Functions

Link to this macro

a ~> b

(macro)

mixfix version of as function

Link to this macro

as(a, b)

(macro)

Stands for AS

Examples

import Ecto.Query
import Ecto.Query.Timescaledb

from(s in Stat,
  select: as(sum(s.avg), avg),
  order_by: [desc: fragment("avg")]
)
Link to this macro

histogram(value, min, max, nbuckets)

(macro)

histogram

Examples

import Ecto.Query
import Ecto.Query.Timescaledb

from(r in Readings,
  select: [r.device_id, histogram(r.battery_level, 20, 60, 5)],
  group_by: r.device_id,
  limit: 10
)
Link to this macro

time_bucket(bucket_width, ts, name)

(macro)

time_bucket extension in timescaledb

Examples

import Ecto.Query
import Ecto.Query.Timescaledb

from(s in Stat,
  select: [time_bucket("7 days", time, bucket), sum(s.avg)],
  group_by: fragment("bucket"),
  order_by: [desc: fragment("bucket")]
)
Link to this macro

time_bucket_ng(bucket_width, ts)

(macro)

time_bucket_ng extension in timescaledb