项目作者: scimas

项目描述 :
Apache Druid querying library for Julia
高级语言: Julia
项目地址: git://github.com/scimas/Druid.jl.git
创建时间: 2021-02-26T16:01:54Z
项目社区:https://github.com/scimas/Druid.jl

开源协议:MIT License

下载


Druid.jl

Apache Druid querying library.

Installation

  1. pkg> add Druid

Usage

Native Query

Druid native queries
documentation

  1. using Druid
  2. client = Client("http://localhost:8888")
  3. timeseries_query = Timeseries(
  4. dataSource=Table("wikipedia"),
  5. intervals=[Interval("2015-09-12","2015-09-13")],
  6. granularity=SimpleGranularity("hour"),
  7. aggregations=[Count("total_rows"), SingleField("longSum", "added", "documents_added")]
  8. )
  9. println(execute(client, timeseries_query))

SQL Query

Druid SQL
documentation

  1. using Druid
  2. client = Client("http://localhost:8888")
  3. sql_query = Sql(query="""
  4. SELECT FLOOR(__time TO HOUR) AS "timestamp", COUNT(*) AS "total_rows", SUM("added") AS "documents_added"
  5. FROM wikipedia
  6. WHERE __time >= TIMESTAMP '2015-09-12' AND __time < TIMESTAMP '2015-09-13'
  7. GROUP BY FLOOR(__time TO HOUR)
  8. ORDER BY "timestamp" ASC
  9. """)
  10. println(execute(client, sql_query))

Tables.jl compatibility

Most queries return the query response as an object compatible with the
Tables.jl interface. So it is quite easy to convert the result into another
compatible type, like DataFrame.

  1. result = execute(client, query)
  2. df = DataFrame(result)

Compatible queries: Timeseries, TopN, GroupBy, Scan, Search, Sql.

Sql query returns the result as either a Druid.SqlResult{ResultFormat} or a
CSV.File depending on the resultFormat provided in the SQL query. Both are
compatible with the Tables.jl interface.

TimeBoundary, SegmentMetadata and DatasourceMetadata return their results
as Dicts.