| "use strict";(self.webpackChunk=self.webpackChunk||[]).push([[6277],{28453:(e,n,t)=>{t.d(n,{R:()=>o,x:()=>r});var i=t(96540);const a={},s=i.createContext(a);function o(e){const n=i.useContext(s);return i.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:o(e.components),i.createElement(s.Provider,{value:n},e.children)}},54432:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>m,contentTitle:()=>r,default:()=>d,frontMatter:()=>o,metadata:()=>i,toc:()=>c});const i=JSON.parse('{"id":"development/extensions-contrib/time-min-max","title":"Timestamp Min/Max aggregators","description":"\x3c!--","source":"@site/docs/latest/development/extensions-contrib/time-min-max.md","sourceDirName":"development/extensions-contrib","slug":"/development/extensions-contrib/time-min-max","permalink":"/docs/latest/development/extensions-contrib/time-min-max","draft":false,"unlisted":false,"tags":[],"version":"current","frontMatter":{"id":"time-min-max","title":"Timestamp Min/Max aggregators"}}');var a=t(74848),s=t(28453);const o={id:"time-min-max",title:"Timestamp Min/Max aggregators"},r=void 0,m={},c=[];function l(e){const n={a:"a",code:"code",p:"p",pre:"pre",...(0,s.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(n.p,{children:["To use this Apache Druid extension, ",(0,a.jsx)(n.a,{href:"/docs/latest/configuration/extensions#loading-extensions",children:"include"})," ",(0,a.jsx)(n.code,{children:"druid-time-min-max"})," in the extensions load list."]}),"\n",(0,a.jsxs)(n.p,{children:["These aggregators enable more precise calculation of min and max time of given events than ",(0,a.jsx)(n.code,{children:"__time"}),' column whose granularity is sparse, the same as query granularity.\nTo use this feature, a "timeMin" or "timeMax" aggregator must be included at indexing time.\nThey can apply to any columns that can be converted to timestamp, which include Long, DateTime, Timestamp, and String types.']}),"\n",(0,a.jsx)(n.p,{children:"For example, when a data set consists of timestamp, dimension, and metric value like followings."}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{children:"2015-07-28T01:00:00.000Z A 1\n2015-07-28T02:00:00.000Z A 1\n2015-07-28T03:00:00.000Z A 1\n2015-07-28T04:00:00.000Z B 1\n2015-07-28T05:00:00.000Z A 1\n2015-07-28T06:00:00.000Z B 1\n2015-07-29T01:00:00.000Z C 1\n2015-07-29T02:00:00.000Z C 1\n2015-07-29T03:00:00.000Z A 1\n2015-07-29T04:00:00.000Z A 1\n"})}),"\n",(0,a.jsx)(n.p,{children:"At ingestion time, timeMin and timeMax aggregator can be included as other aggregators."}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-json",children:'{\n "type": "timeMin",\n "name": "tmin",\n "fieldName": "<field_name, typically column specified in timestamp spec>"\n}\n'})}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-json",children:'{\n "type": "timeMax",\n "name": "tmax",\n "fieldName": "<field_name, typically column specified in timestamp spec>"\n}\n'})}),"\n",(0,a.jsxs)(n.p,{children:[(0,a.jsx)(n.code,{children:"name"})," is output name of aggregator and can be any string. ",(0,a.jsx)(n.code,{children:"fieldName"})," is typically column specified in timestamp spec but can be any column that can be converted to timestamp."]}),"\n",(0,a.jsx)(n.p,{children:'To query for results, the same aggregators "timeMin" and "timeMax" is used.'}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-json",children:'{\n "queryType": "groupBy",\n "dataSource": "timeMinMax",\n "granularity": "DAY",\n "dimensions": ["product"],\n "aggregations": [\n {\n "type": "count",\n "name": "count"\n },\n {\n "type": "timeMin",\n "name": "<output_name of timeMin>",\n "fieldName": "tmin"\n },\n {\n "type": "timeMax",\n "name": "<output_name of timeMax>",\n "fieldName": "tmax"\n }\n ],\n "intervals": [\n "2010-01-01T00:00:00.000Z/2020-01-01T00:00:00.000Z"\n ]\n}\n'})}),"\n",(0,a.jsx)(n.p,{children:"Then, result has min and max of timestamp, which is finer than query granularity."}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{children:"2015-07-28T00:00:00.000Z A 4 2015-07-28T01:00:00.000Z 2015-07-28T05:00:00.000Z\n2015-07-28T00:00:00.000Z B 2 2015-07-28T04:00:00.000Z 2015-07-28T06:00:00.000Z\n2015-07-29T00:00:00.000Z A 2 2015-07-29T03:00:00.000Z 2015-07-29T04:00:00.000Z\n2015-07-29T00:00:00.000Z C 2 2015-07-29T01:00:00.000Z 2015-07-29T02:00:00.000Z\n"})})]})}function d(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,a.jsx)(n,{...e,children:(0,a.jsx)(l,{...e})}):l(e)}}}]); |