initial commit

This commit is contained in:
Guillaume Buisson 2014-09-11 16:18:25 +02:00
parent 4d0bc602ad
commit a0fcf4e08c
5 changed files with 96 additions and 2 deletions

View file

@ -1,2 +1,5 @@
clj-druid
=========
# clj-druid
Clojure library for [Druid](http://druid.io/).
Currently in very early stage, contains schemas to validate a Druid query.

3
doc/intro.md Normal file
View file

@ -0,0 +1,3 @@
# Introduction to clj-druid
TODO: write [great documentation](http://jacobian.org/writing/what-to-write/)

7
project.clj Normal file
View file

@ -0,0 +1,7 @@
(defproject clj-druid "0.1.0-SNAPSHOT"
:description "Clojure library for Druid.io"
:url "http://example.com/FIXME"
:license {:name "MIT"
:url "http://opensource.org/licenses/MIT"}
:dependencies [[org.clojure/clojure "1.6.0"]
[prismatic/schema "0.2.6"]])

74
src/clj_druid/schemas.clj Normal file
View file

@ -0,0 +1,74 @@
(ns clj-druid.schemas
(:require [schema.core :as s]))
(s/defschema granularity
"Druid Granularity option schema"
(s/enum :all
:none
:minute
:fifteen_minute
:thirty_minute
:hour
:day))
(s/defschema limitSpec
"Druid limitSpec option schema"
{:type String :limit Long :columns [String]})
(s/defschema filterSchema
"Druid filter field option schema"
{:type (s/enum :selector :regex :and :or :not)
(s/optional-key :dimension) String
(s/optional-key :value) String
(s/optional-key :pattern) String
(s/optional-key :fields) [filterSchema]
(s/optional-key :field) filterSchema})
(s/defschema aggregationSchema
"Druid filter field option schema"
{:type (s/enum :count :longSum :doubleSum :min :max)
:name String
(s/optional-key :fieldName) String})
(s/defschema postAggregationSchema
"Druid filter field option schema"
{:type (s/enum :arithmetic :fieldAccess :constant)
:name String
(s/optional-key :fieldName) String
(s/optional-key :value) String})
(s/defschema intervalSchema
"Druid interval schema"
[String])
(s/defschema havingSchema
{:type (s/enum :equalTo
:greaterThan
:lessThan
:and
:or
:not)
(s/optional-key :aggregation) String
(s/optional-key :value) String
(s/optional-key :havingSpecs) [havingSchema]})
(s/defschema druidQuery
"Main druid query schema"
{:queryType (s/enum :groupBy
:search
:segmentMetadata
:timeBoundary
:timeseries
:topN)
:dataSource String
:dimensions [String]
:limitSpec limitSpec
:having havingSchema
:granularity granularity
:filter filterSchema
:aggregations aggregationSchema
:postAggregations postAggregationSchema
:intervals intervalSchema})

View file

@ -0,0 +1,7 @@
(ns clj-druid.core-test
(:require [clojure.test :refer :all]
[clj-druid.core :refer :all]))
(deftest a-test
(testing "FIXME, I fail."
(is (= 0 1))))