All Projects β†’ zapr-oss β†’ Druidry

zapr-oss / Druidry

Licence: apache-2.0
Java based Druid Query Generator library

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Druidry

Biota
A simple database framework for Fauna
Stars: ✭ 54 (-68.97%)
Mutual labels:  query-builder, database, client
Squid
πŸ¦‘ Provides SQL tagged template strings and schema definition functions.
Stars: ✭ 57 (-67.24%)
Mutual labels:  query-builder, database
Nodejs Driver
DataStax Node.js Driver for Apache Cassandra
Stars: ✭ 1,074 (+517.24%)
Mutual labels:  database, client
Evolutility Server Node
Model-driven REST or GraphQL backend for CRUD and more, written in Javascript, using Node.js, Express, and PostgreSQL.
Stars: ✭ 84 (-51.72%)
Mutual labels:  query-builder, database
Sqlz
SQL Query Builder for Go
Stars: ✭ 36 (-79.31%)
Mutual labels:  query-builder, database
Faunadb Jvm
Scala and Java driver for FaunaDB
Stars: ✭ 50 (-71.26%)
Mutual labels:  database, client
Kitura Redis
Swift Redis library
Stars: ✭ 84 (-51.72%)
Mutual labels:  database, client
Faunadb Js
Javascript driver for FaunaDB
Stars: ✭ 498 (+186.21%)
Mutual labels:  database, client
Node Druid Query
Simple querying library for Druid (http://druid.io)
Stars: ✭ 93 (-46.55%)
Mutual labels:  druid, client
Postguard
πŸ› Statically validate Postgres SQL queries in JS / TS code and derive schemas.
Stars: ✭ 104 (-40.23%)
Mutual labels:  query-builder, database
Ship Hold
data access framework for Postgresql on nodejs
Stars: ✭ 110 (-36.78%)
Mutual labels:  query-builder, database
Pecee Pixie
Lightweight, easy-to-use querybuilder for PHP inspired by Laravel Eloquent - but with less overhead.
Stars: ✭ 19 (-89.08%)
Mutual labels:  query-builder, database
Reiner
萊納 - A MySQL wrapper which might be better than the ORMs and written in Golang
Stars: ✭ 19 (-89.08%)
Mutual labels:  query-builder, database
Querybuilder
SQL query builder, written in c#, helps you build complex queries easily, supports SqlServer, MySql, PostgreSql, Oracle, Sqlite and Firebird
Stars: ✭ 2,111 (+1113.22%)
Mutual labels:  query-builder, database
Laravel Eloquent Query Cache
Adding cache on your Laravel Eloquent queries' results is now a breeze.
Stars: ✭ 529 (+204.02%)
Mutual labels:  query-builder, database
Faunadb Python
Python driver for FaunaDB
Stars: ✭ 75 (-56.9%)
Mutual labels:  database, client
Ruby Pg
A PostgreSQL client library for Ruby
Stars: ✭ 446 (+156.32%)
Mutual labels:  database, client
Csharp Driver
DataStax C# Driver for Apache Cassandra
Stars: ✭ 477 (+174.14%)
Mutual labels:  database, client
Clickhouse.client
.NET client for ClickHouse
Stars: ✭ 85 (-51.15%)
Mutual labels:  database, client
Faunadb Go
Go driver for FaunaDB
Stars: ✭ 140 (-19.54%)
Mutual labels:  database, client

Welcome to project Druidry!

build_status License: Apache License 2 javadoc

Druid is an extremely popular tool to perform OLAP queries on event data. Druid drives real-time dashboards in most of the organisations right now. [email protected] love Druid! Therefore we want to contribute towards making Druid, even more, friendlier to the ever expanding community.

We want to make the process of deep meaningful conversations with Druid little easier. What do we mean is that we don’t want developers to write big, scary JSON anymore but instead use a simple Java-based query generator to help with the querying.

Creating JSON freely can cause tedious bugs such as date type mistakes or spelling mistakes and potentially code can get bigger and messier and less readable. So, in reality, we want to keep the main focus of querying to be the use-case, not the type-checks.

We are excited to know whether you liked it or loved it, so please reach out to us at [email protected]

Description

Druidry is an open-source Java based utility library which supports creating query to Druid automatically taking care of following,

  • Type checking.
  • Spelling Checks.
  • Code reviewability and readability.

This library is still growing and does not support each and every constructs, however it supports the most common one used internally @Zapr.

Getting Started

Prerequisite

  • Maven
  • Java 8

Usage

Add this in your pom.xml (assuming maven based project)

        <dependency>
            <groupId>in.zapr.druid</groupId>
            <artifactId>druidry</artifactId>
            <version>${LATEST_VERSION}</version>
        </dependency>

Replace ${LATEST_VERSION} with latest release version

Examples

Taking from Druid's example query


{
     "queryType": "topN",
     "dataSource": "sample_data",
     "dimension": "sample_dim",
     "threshold": 5,
     "metric": "count",
     "granularity": "all",
     "filter": {
        "type": "and",
          "fields": [
            {
              "type": "selector",
              "dimension": "dim1",
              "value": "some_value"
            },
            {
              "type": "selector",
              "dimension": "dim2",
              "value": "some_other_val"
            }
          ]
     },
     "aggregations": [
        {
          "type": "longSum",
          "name": "count",
          "fieldName": "count"
        },
        {
          "type": "doubleSum",
          "name": "some_metric",
          "fieldName": "some_metric"
        }
     ],
     "postAggregations": [
         {
            "type": "arithmetic",
            "name": "sample_divide",
            "fn": "/",
            "fields": [
              {
                "type": "fieldAccess",
                "name": "some_metric",
                "fieldName": "some_metric"
              },
              {
                "type": "fieldAccess",
                "name": "count",
                "fieldName": "count"
              }
            ]
         }
      ],
      "intervals": [
        "2013-08-31T00:00:00.000/2013-09-03T00:00:00.000"
      ]
}
SelectorFilter selectorFilter1 = new SelectorFilter("dim1", "some_value");
SelectorFilter selectorFilter2 = new SelectorFilter("dim2", "some_other_val");

AndFilter filter = new AndFilter(Arrays.asList(selectorFilter1, selectorFilter2));

DruidAggregator aggregator1 = new LongSumAggregator("count", "count");
DruidAggregator aggregator2 = new DoubleSumAggregator("some_metric", "some_metric");

FieldAccessPostAggregator fieldAccessPostAggregator1
        = new FieldAccessPostAggregator("some_metric", "some_metric");

FieldAccessPostAggregator fieldAccessPostAggregator2
        = new FieldAccessPostAggregator("count", "count");

DruidPostAggregator postAggregator = ArithmeticPostAggregator.builder()
        .name("sample_divide")
        .function(ArithmeticFunction.DIVIDE)
        .fields(Arrays.asList(fieldAccessPostAggregator1, fieldAccessPostAggregator2))
        .build();

DateTime startTime = new DateTime(2013, 8, 31, 0, 0, 0, DateTimeZone.UTC);
DateTime endTime = new DateTime(2013, 9, 3, 0, 0, 0, DateTimeZone.UTC);
Interval interval = new Interval(startTime, endTime);

Granularity granularity = new SimpleGranularity(PredefinedGranularity.ALL);
DruidDimension dimension = new SimpleDimension("sample_dim");
TopNMetric metric = new SimpleMetric("count");

DruidTopNQuery query = DruidTopNQuery.builder()
        .dataSource("sample_data")
        .dimension(dimension)
        .threshold(5)
        .topNMetric(metric)
        .granularity(granularity)
        .filter(filter)
        .aggregators(Arrays.asList(aggregator1, aggregator2))
        .postAggregators(Collections.singletonList(postAggregator))
        .intervals(Collections.singletonList(interval))
        .build();

ObjectMapper mapper = new ObjectMapper();
String requiredJson = mapper.writeValueAsString(query);
DruidConfiguration config =  DruidConfiguration
               .builder()
               .host("druid.io")
               .endpoint("druid/v2/")
               .build();

DruidClient client = new DruidJerseyClient(druidConfiguration);
client.connect();
List<DruidResponse> responses = client.query(query, DruidResponse.class);
client.close();

Supported Features

Queries

  • Aggregation Queries
    • TopN
    • TimeSeries
    • GroupBy
  • DruidScanQuery
  • DruidSelectQuery

Aggregators

  • Cardinality
  • Count
  • DoubleMax
  • DoubleMin
  • DoubleSum
  • DoubleLast
  • DoubleFirst
  • FloatFirst
  • FloatLast
  • Filtered
  • HyperUnique
  • Javascript
  • LongMax
  • LongMin
  • LongSum
  • LongFirst
  • LongLast
  • DistinctCount
  • Histogram
  • Data Sketches
    • ThetaSketch
    • TupleSketch
    • QuantilesSketch
    • HllSketchBuild
    • HllSketchMerge

Filters

  • And
  • Bound
  • In
  • Interval (Without Extraction Function)
  • Javascript
  • Not
  • Or
  • Regex
  • Search (Without Extraction Function)
  • Selector

Post Aggregators

  • Arithmetic
  • Constant
  • FieldAccess
  • HyperUniqueCardinality
  • Javascript
  • Data Sketches
    • Theta Sketch
      • ThetaSketchEstimate
      • ThetaSketchSetOp
    • Tuple Sketch
      • TupleSketchToEstimate
      • TupleSketchToEstimateAndBounds
      • TupleSketchToNumEntries
      • TupleSketchToMeans
      • TupleSketchToVariances
      • TupleSketchToQuantilesSketch
      • TupleSketchSetOp
      • TupleSketchTTest
      • TupleSketchToString
    • Quantiles Sketch
      • QuantilesSketchToQuantile
      • QuantilesSketchToQuantiles
      • QuantilesSketchToHistogram
      • QuantilesSketchToString
    • HLL Sketch
      • HllSketchEstimateWithBounds
      • HllSketchUnion
      • HllSketchToString

Virtual Columns

  • Expression

Granularity

  • Duration
  • Period
  • Predefined

Contact

For any features or bugs, please raise it in issues section

If anything else, get in touch with us at [email protected]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].