diff --git a/README.md b/README.md index 98effdc..7feff1b 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/doc/intro.md b/doc/intro.md new file mode 100644 index 0000000..6a8ee31 --- /dev/null +++ b/doc/intro.md @@ -0,0 +1,3 @@ +# Introduction to clj-druid + +TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) diff --git a/project.clj b/project.clj new file mode 100644 index 0000000..3a9f0cd --- /dev/null +++ b/project.clj @@ -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"]]) diff --git a/src/clj_druid/schemas.clj b/src/clj_druid/schemas.clj new file mode 100644 index 0000000..12800d5 --- /dev/null +++ b/src/clj_druid/schemas.clj @@ -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}) diff --git a/test/clj_druid/core_test.clj b/test/clj_druid/core_test.clj new file mode 100644 index 0000000..96f1efc --- /dev/null +++ b/test/clj_druid/core_test.clj @@ -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))))