From be1a5be5a4b7a6a0ae0fed9fcf71af68b7d46381 Mon Sep 17 00:00:00 2001 From: Guillaume Buisson Date: Fri, 31 Oct 2014 14:59:07 +0100 Subject: [PATCH] added context schema, added the option to all queries --- src/clj_druid/schemas.clj | 36 ++++++++++++++++++++++++++-------- test/clj_druid/client_test.clj | 10 +++++----- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/clj_druid/schemas.clj b/src/clj_druid/schemas.clj index fa639c9..d173915 100644 --- a/src/clj_druid/schemas.clj +++ b/src/clj_druid/schemas.clj @@ -1,6 +1,18 @@ (ns clj-druid.schemas (:require [schema.core :as s])) + + +(s/defschema context + "Druid Context option schema" + {(s/optional-key :timeout) Long + (s/optional-key :priority) Long + (s/optional-key :queryId) s/Any + (s/optional-key :useCache) Boolean + (s/optional-key :populateCache) Boolean + (s/optional-key :bySegment) Boolean + (s/optional-key :finalize) Boolean}) + (s/defschema granularity "Druid Granularity option schema" (s/enum :all @@ -76,7 +88,8 @@ "Druid queryType option query schema" {:type (s/enum :insensitive_contains :fragment) (s/optional-key :value) (s/either String Long) - (s/optional-key :values) [(s/either String Long)]}) + (s/optional-key :values) [(s/either String Long)] + (s/optional-key :context) context}) (s/defschema SearchSort "Druid queryType search sort schema" @@ -105,7 +118,8 @@ (s/optional-key :postAggregations) [postAggregationSchema] (s/optional-key :limitSpec) limitSpec (s/optional-key :having) havingSchema - (s/optional-key :filter) filterSchema}) + (s/optional-key :filter) filterSchema + (s/optional-key :context) context}) (s/defschema search @@ -117,7 +131,8 @@ :granularity granularity :intervals intervalSchema (s/optional-key :searchDimensions) [String] - (s/optional-key :filter) filterSchema}) + (s/optional-key :filter) filterSchema + (s/optional-key :context) context}) (s/defschema select "Select query schema" @@ -129,7 +144,8 @@ (s/optional-key :dimensions) [String] (s/optional-key :pagingSpec) s/Any (s/optional-key :limitSpec) limitSpec - (s/optional-key :filter) filterSchema}) + (s/optional-key :filter) filterSchema + (s/optional-key :context) context}) (s/defschema segmentMetadata @@ -138,7 +154,8 @@ :dataSource String :intervals intervalSchema (s/optional-key :toInclude) SegmentMetadataToInclude - (s/optional-key :merge) Boolean}) + (s/optional-key :merge) Boolean + (s/optional-key :context) context}) @@ -147,7 +164,8 @@ {:queryType (s/enum :timeBoundary) :dataSource String (s/optional-key :toInclude) SegmentMetadataToInclude - (s/optional-key :bound) (s/enum :minTime :maxTime)}) + (s/optional-key :bound) (s/enum :minTime :maxTime) + (s/optional-key :context) context}) (s/defschema timeseries @@ -158,7 +176,8 @@ :aggregations [aggregationSchema] :intervals intervalSchema (s/optional-key :postAggregations) [postAggregationSchema] - (s/optional-key :filter) filterSchema}) + (s/optional-key :filter) filterSchema + (s/optional-key :context) context}) (s/defschema topN @@ -172,7 +191,8 @@ :aggregations [aggregationSchema] :intervals intervalSchema (s/optional-key :postAggregations) [postAggregationSchema] - (s/optional-key :filter) filterSchema}) + (s/optional-key :filter) filterSchema + (s/optional-key :context) context}) (def queries {:groupBy groupBy diff --git a/test/clj_druid/client_test.clj b/test/clj_druid/client_test.clj index 459f615..6bb4394 100644 --- a/test/clj_druid/client_test.clj +++ b/test/clj_druid/client_test.clj @@ -4,14 +4,14 @@ [clj-druid.client :refer :all])) -(deftest test-connect-zookeeper - (connect {:zk {:host "192.168.59.103:2181" - :discovery-path "/discovery" - :node-type "broker"}})) +;; (deftest test-connect-zookeeper +;; (connect {:zk {:host "192.168.59.103:2181" +;; :discovery-path "/discovery" +;; :node-type "broker"}})) (deftest test-connect-user - (connect {:hosts ["http://localhost:8082/druid/v2/"]})) + (connect {:hosts ["http://m1.vigiglo.be:8085/druid/v2/"]})) ;(deftest test-zk-query