Browse Source

initial commit

tags/0.2.16
Guillaume Buisson 7 years ago
parent
commit
a0fcf4e08c
  1. 7
      README.md
  2. 3
      doc/intro.md
  3. 7
      project.clj
  4. 74
      src/clj_druid/schemas.clj
  5. 7
      test/clj_druid/core_test.clj

7
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.

3
doc/intro.md

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

7
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"]])

74
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})

7
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))))
Loading…
Cancel
Save