Define Schema.


I am trying to understand, how to define MetricSpec and DimensionSpec. If I define the numeric fields like “age”, “populationCount”, “salary” in dimensionSpec only, these fields are by default getting ingested as strings.

I understand, at ingestion time metrics - aggregations of type count,longSum,doubleSum,doubleMin, etc are supported.

If I intend to perform aggregations like avg, sum, min, max on above mentioned fields (or many other complex aggregations, which cannot be predicted at ingestion time). How shall I define them to be ingested as numeric types?

I intend to use PlyQL, to query my dataset. Is there any was to define the query time metric type in PlyQl. Can I define, following at ingestion time ?

“metric”: {

“type”: “numeric”,

“metric”: “<metric_name>”


Ref : source

Please provide your inputs, my question might be in wrong direction, as i am trying to learn druid.

Thank you,

Vrinda Davda

AFAIK,currently druid doesn’t support numeric dimensions and by default all dimensions are assumed to be of type String.

Druid drives it major performance gain by aggregating data during ingestion thereby reducing total persisted rows.

It is not advisable to use measures as dimensions because it would lead to non-efficient aggregations due to high cardinality of measures.

Depending on your use case you should define some ingestion aggregations(like count,sum etc) and during query these aggregated values can be used for computing further complex aggregations.

For eg:If you need to compute average of some measures,you can use “sum” and “count” ingestion aggregates and calculate averages during query using query time aggregates functions.

If you let us know your use case in more detail we all can help better.

Numeric dimensions will be supported in 0.9.2.

Dimensions are things you want to filter and group on.

Metrics are things you want to aggregate.

Druid supports post aggregations for things such as AVG.

Thanks Fangjin,

Looking forward to that.

Thank you,

Vrinda Davda

Hi Rohit,

Thank for the reply. This helps.

Thank you,

Vrinda Davda