blob: 197b434d229650a4bd2e25216561810754c8e931 [file] [log] [blame]
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[6170],{3905:(e,t,n)=>{n.d(t,{Zo:()=>p,kt:()=>g});var a=n(67294);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function i(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},l=Object.keys(e);for(a=0;a<l.length;a++)n=l[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a<l.length;a++)n=l[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var o=a.createContext({}),u=function(e){var t=a.useContext(o),n=t;return e&&(n="function"==typeof e?e(t):s(s({},t),e)),n},p=function(e){var t=u(e.components);return a.createElement(o.Provider,{value:t},e.children)},d="mdxType",m={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},c=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,l=e.originalType,o=e.parentName,p=i(e,["components","mdxType","originalType","parentName"]),d=u(n),c=r,g=d["".concat(o,".").concat(c)]||d[c]||m[c]||l;return n?a.createElement(g,s(s({ref:t},p),{},{components:n})):a.createElement(g,s({ref:t},p))}));function g(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var l=n.length,s=new Array(l);s[0]=c;var i={};for(var o in t)hasOwnProperty.call(t,o)&&(i[o]=t[o]);i.originalType=e,i[d]="string"==typeof e?e:r,s[1]=i;for(var u=2;u<l;u++)s[u]=n[u];return a.createElement.apply(null,s)}return a.createElement.apply(null,n)}c.displayName="MDXCreateElement"},85162:(e,t,n)=>{n.d(t,{Z:()=>s});var a=n(67294),r=n(86010);const l={tabItem:"tabItem_Ymn6"};function s(e){var t=e.children,n=e.hidden,s=e.className;return a.createElement("div",{role:"tabpanel",className:(0,r.Z)(l.tabItem,s),hidden:n},t)}},74866:(e,t,n)=>{n.d(t,{Z:()=>T});var a=n(87462),r=n(67294),l=n(86010),s=n(12466),i=n(16550),o=n(91980),u=n(67392),p=n(50012);function d(e){return function(e){var t,n;return null!=(t=null==(n=r.Children.map(e,(function(e){if(!e||(0,r.isValidElement)(e)&&(t=e.props)&&"object"==typeof t&&"value"in t)return e;var t;throw new Error("Docusaurus error: Bad <Tabs> child <"+("string"==typeof e.type?e.type:e.type.name)+'>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.')})))?void 0:n.filter(Boolean))?t:[]}(e).map((function(e){var t=e.props;return{value:t.value,label:t.label,attributes:t.attributes,default:t.default}}))}function m(e){var t=e.values,n=e.children;return(0,r.useMemo)((function(){var e=null!=t?t:d(n);return function(e){var t=(0,u.l)(e,(function(e,t){return e.value===t.value}));if(t.length>0)throw new Error('Docusaurus error: Duplicate values "'+t.map((function(e){return e.value})).join(", ")+'" found in <Tabs>. Every value needs to be unique.')}(e),e}),[t,n])}function c(e){var t=e.value;return e.tabValues.some((function(e){return e.value===t}))}function g(e){var t=e.queryString,n=void 0!==t&&t,a=e.groupId,l=(0,i.k6)(),s=function(e){var t=e.queryString,n=void 0!==t&&t,a=e.groupId;if("string"==typeof n)return n;if(!1===n)return null;if(!0===n&&!a)throw new Error('Docusaurus error: The <Tabs> component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return null!=a?a:null}({queryString:n,groupId:a});return[(0,o._X)(s),(0,r.useCallback)((function(e){if(s){var t=new URLSearchParams(l.location.search);t.set(s,e),l.replace(Object.assign({},l.location,{search:t.toString()}))}}),[s,l])]}function k(e){var t,n,a,l,s=e.defaultValue,i=e.queryString,o=void 0!==i&&i,u=e.groupId,d=m(e),k=(0,r.useState)((function(){return function(e){var t,n=e.defaultValue,a=e.tabValues;if(0===a.length)throw new Error("Docusaurus error: the <Tabs> component requires at least one <TabItem> children component");if(n){if(!c({value:n,tabValues:a}))throw new Error('Docusaurus error: The <Tabs> has a defaultValue "'+n+'" but none of its children has the corresponding value. Available values are: '+a.map((function(e){return e.value})).join(", ")+". If you intend to show no default tab, use defaultValue={null} instead.");return n}var r=null!=(t=a.find((function(e){return e.default})))?t:a[0];if(!r)throw new Error("Unexpected error: 0 tabValues");return r.value}({defaultValue:s,tabValues:d})})),y=k[0],h=k[1],N=g({queryString:o,groupId:u}),f=N[0],b=N[1],T=(t=function(e){return e?"docusaurus.tab."+e:null}({groupId:u}.groupId),n=(0,p.Nk)(t),a=n[0],l=n[1],[a,(0,r.useCallback)((function(e){t&&l.set(e)}),[t,l])]),S=T[0],v=T[1],R=function(){var e=null!=f?f:S;return c({value:e,tabValues:d})?e:null}();return(0,r.useLayoutEffect)((function(){R&&h(R)}),[R]),{selectedValue:y,selectValue:(0,r.useCallback)((function(e){if(!c({value:e,tabValues:d}))throw new Error("Can't select invalid tab value="+e);h(e),b(e),v(e)}),[b,v,d]),tabValues:d}}var y=n(72389);const h={tabList:"tabList__CuJ",tabItem:"tabItem_LNqP"};function N(e){var t=e.className,n=e.block,i=e.selectedValue,o=e.selectValue,u=e.tabValues,p=[],d=(0,s.o5)().blockElementScrollPositionUntilNextRender,m=function(e){var t=e.currentTarget,n=p.indexOf(t),a=u[n].value;a!==i&&(d(t),o(a))},c=function(e){var t,n=null;switch(e.key){case"Enter":m(e);break;case"ArrowRight":var a,r=p.indexOf(e.currentTarget)+1;n=null!=(a=p[r])?a:p[0];break;case"ArrowLeft":var l,s=p.indexOf(e.currentTarget)-1;n=null!=(l=p[s])?l:p[p.length-1]}null==(t=n)||t.focus()};return r.createElement("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,l.Z)("tabs",{"tabs--block":n},t)},u.map((function(e){var t=e.value,n=e.label,s=e.attributes;return r.createElement("li",(0,a.Z)({role:"tab",tabIndex:i===t?0:-1,"aria-selected":i===t,key:t,ref:function(e){return p.push(e)},onKeyDown:c,onClick:m},s,{className:(0,l.Z)("tabs__item",h.tabItem,null==s?void 0:s.className,{"tabs__item--active":i===t})}),null!=n?n:t)})))}function f(e){var t=e.lazy,n=e.children,a=e.selectedValue,l=(Array.isArray(n)?n:[n]).filter(Boolean);if(t){var s=l.find((function(e){return e.props.value===a}));return s?(0,r.cloneElement)(s,{className:"margin-top--md"}):null}return r.createElement("div",{className:"margin-top--md"},l.map((function(e,t){return(0,r.cloneElement)(e,{key:t,hidden:e.props.value!==a})})))}function b(e){var t=k(e);return r.createElement("div",{className:(0,l.Z)("tabs-container",h.tabList)},r.createElement(N,(0,a.Z)({},e,t)),r.createElement(f,(0,a.Z)({},e,t)))}function T(e){var t=(0,y.Z)();return r.createElement(b,(0,a.Z)({key:String(t)},e))}},34735:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>m,contentTitle:()=>p,default:()=>y,frontMatter:()=>u,metadata:()=>d,toc:()=>c});var a=n(87462),r=n(63366),l=(n(67294),n(3905)),s=n(74866),i=n(85162),o=["components"],u={id:"sql-ingestion-api",title:"SQL-based ingestion API",sidebar_label:"SQL-based ingestion"},p=void 0,d={unversionedId:"api-reference/sql-ingestion-api",id:"api-reference/sql-ingestion-api",title:"SQL-based ingestion API",description:"\x3c!--",source:"@site/docs/latest/api-reference/sql-ingestion-api.md",sourceDirName:"api-reference",slug:"/api-reference/sql-ingestion-api",permalink:"/docs/latest/api-reference/sql-ingestion-api",draft:!1,tags:[],version:"current",frontMatter:{id:"sql-ingestion-api",title:"SQL-based ingestion API",sidebar_label:"SQL-based ingestion"},sidebar:"docs",previous:{title:"Druid SQL",permalink:"/docs/latest/api-reference/sql-api"},next:{title:"JSON querying",permalink:"/docs/latest/api-reference/json-querying-api"}},m={},c=[{value:"Submit a query",id:"submit-a-query",level:2},{value:"URL",id:"url",level:3},{value:"Responses",id:"responses",level:3},{value:"Sample request",id:"sample-request",level:3},{value:"Sample response",id:"sample-response",level:3},{value:"Get the status for a query task",id:"get-the-status-for-a-query-task",level:2},{value:"URL",id:"url-1",level:3},{value:"Responses",id:"responses-1",level:3},{value:"Sample request",id:"sample-request-1",level:3},{value:"Sample response",id:"sample-response-1",level:3},{value:"Get the report for a query task",id:"get-the-report-for-a-query-task",level:2},{value:"URL",id:"url-2",level:3},{value:"Responses",id:"responses-2",level:3},{value:"Sample request",id:"sample-request-2",level:3},{value:"Sample response",id:"sample-response-2",level:3},{value:"Cancel a query task",id:"cancel-a-query-task",level:2},{value:"URL",id:"url-3",level:3},{value:"Responses",id:"responses-3",level:3},{value:"Sample request",id:"sample-request-3",level:3},{value:"Sample response",id:"sample-response-3",level:3}],g={toc:c},k="wrapper";function y(e){var t=e.components,n=(0,r.Z)(e,o);return(0,l.kt)(k,(0,a.Z)({},g,n,{components:t,mdxType:"MDXLayout"}),(0,l.kt)("admonition",{type:"info"},(0,l.kt)("p",{parentName:"admonition"}," This page describes SQL-based batch ingestion using the ",(0,l.kt)("a",{parentName:"p",href:"/docs/latest/multi-stage-query/"},(0,l.kt)("inlineCode",{parentName:"a"},"druid-multi-stage-query")),"\nextension, new in Druid 24.0. Refer to the ",(0,l.kt)("a",{parentName:"p",href:"/docs/latest/ingestion/#batch"},"ingestion methods")," table to determine which\ningestion method is right for you.")),(0,l.kt)("p",null,"The ",(0,l.kt)("strong",{parentName:"p"},"Query")," view in the web console provides a friendly experience for the multi-stage query task engine (MSQ task engine) and multi-stage query architecture. We recommend using the web console if you don't need a programmatic interface."),(0,l.kt)("p",null,"When using the API for the MSQ task engine, the action you want to take determines the endpoint you use:"),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"/druid/v2/sql/task"),": Submit a query for ingestion."),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"/druid/indexer/v1/task"),": Interact with a query, including getting its status or details, or canceling the query. This page describes a few of the Overlord Task APIs that you can use with the MSQ task engine. For information about Druid APIs, see the ",(0,l.kt)("a",{parentName:"li",href:"/docs/latest/ingestion/tasks"},"API reference for Druid"),".")),(0,l.kt)("p",null,"In this topic, ",(0,l.kt)("inlineCode",{parentName:"p"},"http://ROUTER_IP:ROUTER_PORT")," is a placeholder for your Router service address and port. Replace it with the information for your deployment. For example, use ",(0,l.kt)("inlineCode",{parentName:"p"},"http://localhost:8888")," for quickstart deployments."),(0,l.kt)("h2",{id:"submit-a-query"},"Submit a query"),(0,l.kt)("p",null,"Submits queries to the MSQ task engine."),(0,l.kt)("p",null,"The ",(0,l.kt)("inlineCode",{parentName:"p"},"/druid/v2/sql/task")," endpoint accepts the following:"),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("a",{parentName:"li",href:"/docs/latest/api-reference/sql-api#request-body"},"SQL requests in the JSON-over-HTTP form")," using the\n",(0,l.kt)("inlineCode",{parentName:"li"},"query"),", ",(0,l.kt)("inlineCode",{parentName:"li"},"context"),", and ",(0,l.kt)("inlineCode",{parentName:"li"},"parameters")," fields. The endpoint ignores the ",(0,l.kt)("inlineCode",{parentName:"li"},"resultFormat"),", ",(0,l.kt)("inlineCode",{parentName:"li"},"header"),", ",(0,l.kt)("inlineCode",{parentName:"li"},"typesHeader"),", and ",(0,l.kt)("inlineCode",{parentName:"li"},"sqlTypesHeader")," fields."),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("a",{parentName:"li",href:"/docs/latest/multi-stage-query/reference#insert"},"INSERT")," and ",(0,l.kt)("a",{parentName:"li",href:"/docs/latest/multi-stage-query/reference#replace"},"REPLACE")," statements."),(0,l.kt)("li",{parentName:"ul"},"SELECT queries (experimental feature). SELECT query results are collected from workers by the controller, and written into the ",(0,l.kt)("a",{parentName:"li",href:"#get-the-report-for-a-query-task"},"task report")," as an array of arrays. The behavior and result format of plain SELECT queries (without INSERT or REPLACE) is subject to change.")),(0,l.kt)("h3",{id:"url"},"URL"),(0,l.kt)("p",null,(0,l.kt)("inlineCode",{parentName:"p"},"POST")," ",(0,l.kt)("inlineCode",{parentName:"p"},"/druid/v2/sql/task")),(0,l.kt)("h3",{id:"responses"},"Responses"),(0,l.kt)(s.Z,{mdxType:"Tabs"},(0,l.kt)(i.Z,{value:"1",label:"200 SUCCESS",mdxType:"TabItem"},(0,l.kt)("p",null,(0,l.kt)("em",{parentName:"p"},"Successfully submitted query"))),(0,l.kt)(i.Z,{value:"2",label:"400 BAD REQUEST",mdxType:"TabItem"},(0,l.kt)("p",null,(0,l.kt)("em",{parentName:"p"},"Error thrown due to bad query. Returns a JSON object detailing the error with the following format:")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-json"},'{\n "error": "A well-defined error code.",\n "errorMessage": "A message with additional details about the error.",\n "errorClass": "Class of exception that caused this error.",\n "host": "The host on which the error occurred."\n}\n'))),(0,l.kt)(i.Z,{value:"3",label:"500 INTERNAL SERVER ERROR",mdxType:"TabItem"},(0,l.kt)("p",null,(0,l.kt)("em",{parentName:"p"},"Request not sent due to unexpected conditions. Returns a JSON object detailing the error with the following format:")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-json"},'{\n "error": "A well-defined error code.",\n "errorMessage": "A message with additional details about the error.",\n "errorClass": "Class of exception that caused this error.",\n "host": "The host on which the error occurred."\n}\n')))),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"sample-request"},"Sample request"),(0,l.kt)("p",null,"The following example shows a query that fetches data from an external JSON source and inserts it into a table named ",(0,l.kt)("inlineCode",{parentName:"p"},"wikipedia"),"."),(0,l.kt)(s.Z,{mdxType:"Tabs"},(0,l.kt)(i.Z,{value:"4",label:"HTTP",mdxType:"TabItem"},(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-HTTP"},'POST /druid/v2/sql/task HTTP/1.1\nHost: http://ROUTER_IP:ROUTER_PORT\nContent-Type: application/json\n\n{\n "query": "INSERT INTO wikipedia\\nSELECT\\n TIME_PARSE(\\"timestamp\\") AS __time,\\n *\\nFROM TABLE(\\n EXTERN(\\n \'{\\"type\\": \\"http\\", \\"uris\\": [\\"https://druid.apache.org/data/wikipedia.json.gz\\"]}\',\\n \'{\\"type\\": \\"json\\"}\',\\n \'[{\\"name\\": \\"added\\", \\"type\\": \\"long\\"}, {\\"name\\": \\"channel\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"cityName\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"comment\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"commentLength\\", \\"type\\": \\"long\\"}, {\\"name\\": \\"countryIsoCode\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"countryName\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"deleted\\", \\"type\\": \\"long\\"}, {\\"name\\": \\"delta\\", \\"type\\": \\"long\\"}, {\\"name\\": \\"deltaBucket\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"diffUrl\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"flags\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"isAnonymous\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"isMinor\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"isNew\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"isRobot\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"isUnpatrolled\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"metroCode\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"namespace\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"page\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"regionIsoCode\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"regionName\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"timestamp\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"user\\", \\"type\\": \\"string\\"}]\'\\n )\\n)\\nPARTITIONED BY DAY",\n "context": {\n "maxNumTasks": 3\n }\n}\n'))),(0,l.kt)(i.Z,{value:"5",label:"cURL",mdxType:"TabItem"},(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-shell"},'curl --location --request POST \'http://ROUTER_IP:ROUTER_PORT/druid/v2/sql/task\' \\\n --header \'Content-Type: application/json\' \\\n --data-raw \'{\n "query": "INSERT INTO wikipedia\\nSELECT\\n TIME_PARSE(\\"timestamp\\") AS __time,\\n *\\nFROM TABLE(\\n EXTERN(\\n \'\\\'\'{\\"type\\": \\"http\\", \\"uris\\": [\\"https://druid.apache.org/data/wikipedia.json.gz\\"]}\'\\\'\',\\n \'\\\'\'{\\"type\\": \\"json\\"}\'\\\'\',\\n \'\\\'\'[{\\"name\\": \\"added\\", \\"type\\": \\"long\\"}, {\\"name\\": \\"channel\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"cityName\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"comment\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"commentLength\\", \\"type\\": \\"long\\"}, {\\"name\\": \\"countryIsoCode\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"countryName\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"deleted\\", \\"type\\": \\"long\\"}, {\\"name\\": \\"delta\\", \\"type\\": \\"long\\"}, {\\"name\\": \\"deltaBucket\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"diffUrl\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"flags\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"isAnonymous\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"isMinor\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"isNew\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"isRobot\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"isUnpatrolled\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"metroCode\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"namespace\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"page\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"regionIsoCode\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"regionName\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"timestamp\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"user\\", \\"type\\": \\"string\\"}]\'\\\'\'\\n )\\n)\\nPARTITIONED BY DAY",\n "context": {\n "maxNumTasks": 3\n }\n }\'\n'))),(0,l.kt)(i.Z,{value:"6",label:"Python",mdxType:"TabItem"},(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-python"},'import json\nimport requests\n\nurl = "http://ROUTER_IP:ROUTER_PORT/druid/v2/sql/task"\n\npayload = json.dumps({\n "query": "INSERT INTO wikipedia\\nSELECT\\n TIME_PARSE(\\"timestamp\\") AS __time,\\n *\\nFROM TABLE(\\n EXTERN(\\n \'{\\"type\\": \\"http\\", \\"uris\\": [\\"https://druid.apache.org/data/wikipedia.json.gz\\"]}\',\\n \'{\\"type\\": \\"json\\"}\',\\n \'[{\\"name\\": \\"added\\", \\"type\\": \\"long\\"}, {\\"name\\": \\"channel\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"cityName\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"comment\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"commentLength\\", \\"type\\": \\"long\\"}, {\\"name\\": \\"countryIsoCode\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"countryName\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"deleted\\", \\"type\\": \\"long\\"}, {\\"name\\": \\"delta\\", \\"type\\": \\"long\\"}, {\\"name\\": \\"deltaBucket\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"diffUrl\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"flags\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"isAnonymous\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"isMinor\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"isNew\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"isRobot\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"isUnpatrolled\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"metroCode\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"namespace\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"page\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"regionIsoCode\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"regionName\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"timestamp\\", \\"type\\": \\"string\\"}, {\\"name\\": \\"user\\", \\"type\\": \\"string\\"}]\'\\n )\\n)\\nPARTITIONED BY DAY",\n "context": {\n "maxNumTasks": 3\n }\n})\nheaders = {\n \'Content-Type\': \'application/json\'\n}\n\nresponse = requests.post(url, headers=headers, data=payload, auth=(\'USER\', \'PASSWORD\'))\n\nprint(response.text)\n\n')))),(0,l.kt)("h3",{id:"sample-response"},"Sample response"),(0,l.kt)("details",null,(0,l.kt)("summary",null,"View the response"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-json"},'{\n "taskId": "query-f795a235-4dc7-4fef-abac-3ae3f9686b79",\n "state": "RUNNING",\n}\n'))),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Response fields")),(0,l.kt)("table",null,(0,l.kt)("thead",{parentName:"table"},(0,l.kt)("tr",{parentName:"thead"},(0,l.kt)("th",{parentName:"tr",align:null},"Field"),(0,l.kt)("th",{parentName:"tr",align:null},"Description"))),(0,l.kt)("tbody",{parentName:"table"},(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"taskId")),(0,l.kt)("td",{parentName:"tr",align:null},"Controller task ID. You can use Druid's standard ",(0,l.kt)("a",{parentName:"td",href:"/docs/latest/api-reference/tasks-api"},"Tasks API")," to interact with this controller task.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"state")),(0,l.kt)("td",{parentName:"tr",align:null},"Initial state for the query.")))),(0,l.kt)("h2",{id:"get-the-status-for-a-query-task"},"Get the status for a query task"),(0,l.kt)("p",null,"Retrieves the status of a query task. It returns a JSON object with the task's status code, runner status, task type, datasource, and other relevant metadata."),(0,l.kt)("h3",{id:"url-1"},"URL"),(0,l.kt)("p",null,(0,l.kt)("inlineCode",{parentName:"p"},"GET")," ",(0,l.kt)("inlineCode",{parentName:"p"},"/druid/indexer/v1/task/{taskId}/status")),(0,l.kt)("h3",{id:"responses-1"},"Responses"),(0,l.kt)(s.Z,{mdxType:"Tabs"},(0,l.kt)(i.Z,{value:"7",label:"200 SUCCESS",mdxType:"TabItem"},(0,l.kt)("br",null),(0,l.kt)("p",null,(0,l.kt)("em",{parentName:"p"},"Successfully retrieved task status"))),(0,l.kt)(i.Z,{value:"8",label:"404 NOT FOUND",mdxType:"TabItem"},(0,l.kt)("br",null),(0,l.kt)("p",null,(0,l.kt)("em",{parentName:"p"},"Cannot find task with ID")))),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"sample-request-1"},"Sample request"),(0,l.kt)("p",null,"The following example shows how to retrieve the status of a task with the ID ",(0,l.kt)("inlineCode",{parentName:"p"},"query-3dc0c45d-34d7-4b15-86c9-cdb2d3ebfc4e"),"."),(0,l.kt)(s.Z,{mdxType:"Tabs"},(0,l.kt)(i.Z,{value:"9",label:"HTTP",mdxType:"TabItem"},(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-HTTP"},"GET /druid/indexer/v1/task/query-3dc0c45d-34d7-4b15-86c9-cdb2d3ebfc4e/status HTTP/1.1\nHost: http://ROUTER_IP:ROUTER_PORT\n"))),(0,l.kt)(i.Z,{value:"10",label:"cURL",mdxType:"TabItem"},(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-shell"},"curl --location --request GET 'http://ROUTER_IP:ROUTER_PORT/druid/indexer/v1/task/query-3dc0c45d-34d7-4b15-86c9-cdb2d3ebfc4e/status'\n"))),(0,l.kt)(i.Z,{value:"11",label:"Python",mdxType:"TabItem"},(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-python"},"import requests\n\nurl = \"http://ROUTER_IP:ROUTER_PORT/druid/indexer/v1/task/query-3dc0c45d-34d7-4b15-86c9-cdb2d3ebfc4e/status\"\n\npayload={}\nheaders = {}\n\nresponse = requests.get(url, headers=headers, data=payload, auth=('USER', 'PASSWORD'))\n\nprint(response.text)\n")))),(0,l.kt)("h3",{id:"sample-response-1"},"Sample response"),(0,l.kt)("details",null,(0,l.kt)("summary",null,"View the response"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-json"},'{\n "task": "query-3dc0c45d-34d7-4b15-86c9-cdb2d3ebfc4e",\n "status": {\n "id": "query-3dc0c45d-34d7-4b15-86c9-cdb2d3ebfc4e",\n "groupId": "query-3dc0c45d-34d7-4b15-86c9-cdb2d3ebfc4e",\n "type": "query_controller",\n "createdTime": "2022-09-14T22:12:00.183Z",\n "queueInsertionTime": "1970-01-01T00:00:00.000Z",\n "statusCode": "RUNNING",\n "status": "RUNNING",\n "runnerStatusCode": "RUNNING",\n "duration": -1,\n "location": {\n "host": "localhost",\n "port": 8100,\n "tlsPort": -1\n },\n "dataSource": "kttm_simple",\n "errorMsg": null\n }\n}\n'))),(0,l.kt)("h2",{id:"get-the-report-for-a-query-task"},"Get the report for a query task"),(0,l.kt)("p",null,"Retrieves the task report for a query.\nThe report provides detailed information about the query task, including things like the stages, warnings, and errors."),(0,l.kt)("p",null,"Keep the following in mind when using the task API to view reports:"),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},"The task report for an entire job is associated with the ",(0,l.kt)("inlineCode",{parentName:"li"},"query_controller")," task. The ",(0,l.kt)("inlineCode",{parentName:"li"},"query_worker")," tasks don't have their own reports; their information is incorporated into the controller report."),(0,l.kt)("li",{parentName:"ul"},"The task report API may report ",(0,l.kt)("inlineCode",{parentName:"li"},"404 Not Found")," temporarily while the task is in the process of starting up."),(0,l.kt)("li",{parentName:"ul"},"As an experimental feature, the MSQ task engine supports running SELECT queries. SELECT query results are written into\nthe ",(0,l.kt)("inlineCode",{parentName:"li"},"multiStageQuery.payload.results.results")," task report key as an array of arrays. The behavior and result format of plain\nSELECT queries (without INSERT or REPLACE) is subject to change."),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"multiStageQuery.payload.results.resultsTruncated")," denotes whether the results of the report have been truncated to prevent the reports from blowing up.")),(0,l.kt)("p",null,"For an explanation of the fields in a report, see ",(0,l.kt)("a",{parentName:"p",href:"#report-response-fields"},"Report response fields"),"."),(0,l.kt)("h3",{id:"url-2"},"URL"),(0,l.kt)("p",null,(0,l.kt)("inlineCode",{parentName:"p"},"GET")," ",(0,l.kt)("inlineCode",{parentName:"p"},"/druid/indexer/v1/task/{taskId}/reports")),(0,l.kt)("h3",{id:"responses-2"},"Responses"),(0,l.kt)(s.Z,{mdxType:"Tabs"},(0,l.kt)(i.Z,{value:"12",label:"200 SUCCESS",mdxType:"TabItem"},(0,l.kt)("br",null),(0,l.kt)("p",null,(0,l.kt)("em",{parentName:"p"},"Successfully retrieved task report")))),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"sample-request-2"},"Sample request"),(0,l.kt)("p",null,"The following example shows how to retrieve the report for a query with the task ID ",(0,l.kt)("inlineCode",{parentName:"p"},"query-3dc0c45d-34d7-4b15-86c9-cdb2d3ebfc4e"),"."),(0,l.kt)(s.Z,{mdxType:"Tabs"},(0,l.kt)(i.Z,{value:"13",label:"HTTP",mdxType:"TabItem"},(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-HTTP"},"GET /druid/indexer/v1/task/query-3dc0c45d-34d7-4b15-86c9-cdb2d3ebfc4e/reports HTTP/1.1\nHost: http://ROUTER_IP:ROUTER_PORT\n"))),(0,l.kt)(i.Z,{value:"14",label:"cURL",mdxType:"TabItem"},(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-shell"},"curl --location --request GET 'http://ROUTER_IP:ROUTER_PORT/druid/indexer/v1/task/query-3dc0c45d-34d7-4b15-86c9-cdb2d3ebfc4e/reports'\n"))),(0,l.kt)(i.Z,{value:"15",label:"Python",mdxType:"TabItem"},(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-python"},"import requests\n\nurl = \"http://ROUTER_IP:ROUTER_PORT/druid/indexer/v1/task/query-3dc0c45d-34d7-4b15-86c9-cdb2d3ebfc4e/reports\"\n\nheaders = {}\nresponse = requests.get(url, headers=headers, auth=('USER', 'PASSWORD'))\nprint(response.text)\n")))),(0,l.kt)("h3",{id:"sample-response-2"},"Sample response"),(0,l.kt)("p",null,"The response shows an example report for a query."),(0,l.kt)("details",null,(0,l.kt)("summary",null,"View the response"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-json"},'{\n "multiStageQuery": {\n "type": "multiStageQuery",\n "taskId": "query-3dc0c45d-34d7-4b15-86c9-cdb2d3ebfc4e",\n "payload": {\n "status": {\n "status": "SUCCESS",\n "startTime": "2022-09-14T22:12:09.266Z",\n "durationMs": 28227,\n "workers": {\n "0": [\n {\n "workerId": "query-3dc0c45d-34d7-4b15-86c9-cdb2d3ebfc4e-worker0_0",\n "state": "SUCCESS",\n "durationMs": 15511,\n "pendingMs": 137\n }\n ]\n },\n "pendingTasks": 0,\n "runningTasks": 2,\n "segmentLoadWaiterStatus": {\n "state": "SUCCESS",\n "dataSource": "kttm_simple",\n "startTime": "2022-09-14T23:12:09.266Z",\n "duration": 15,\n "totalSegments": 1,\n "usedSegments": 1,\n "precachedSegments": 0,\n "onDemandSegments": 0,\n "pendingSegments": 0,\n "unknownSegments": 0\n },\n "segmentReport": {\n "shardSpec": "NumberedShardSpec",\n "details": "Cannot use RangeShardSpec, RangedShardSpec only supports string CLUSTER BY keys. Using NumberedShardSpec instead."\n }\n },\n "stages": [\n {\n "stageNumber": 0,\n "definition": {\n "id": "71ecb11e-09d7-42f8-9225-1662c8e7e121_0",\n "input": [\n {\n "type": "external",\n "inputSource": {\n "type": "http",\n "uris": [\n "https://static.imply.io/example-data/kttm-v2/kttm-v2-2019-08-25.json.gz"\n ],\n "httpAuthenticationUsername": null,\n "httpAuthenticationPassword": null\n },\n "inputFormat": {\n "type": "json",\n "flattenSpec": null,\n "featureSpec": {},\n "keepNullColumns": false\n },\n "signature": [\n {\n "name": "timestamp",\n "type": "STRING"\n },\n {\n "name": "agent_category",\n "type": "STRING"\n },\n {\n "name": "agent_type",\n "type": "STRING"\n }\n ]\n }\n ],\n "processor": {\n "type": "scan",\n "query": {\n "queryType": "scan",\n "dataSource": {\n "type": "inputNumber",\n "inputNumber": 0\n },\n "intervals": {\n "type": "intervals",\n "intervals": [\n "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z"\n ]\n },\n "resultFormat": "compactedList",\n "columns": [\n "agent_category",\n "agent_type",\n "timestamp"\n ],\n "legacy": false,\n "context": {\n "finalize": false,\n "finalizeAggregations": false,\n "groupByEnableMultiValueUnnesting": false,\n "scanSignature": "[{\\"name\\":\\"agent_category\\",\\"type\\":\\"STRING\\"},{\\"name\\":\\"agent_type\\",\\"type\\":\\"STRING\\"},{\\"name\\":\\"timestamp\\",\\"type\\":\\"STRING\\"}]",\n "sqlInsertSegmentGranularity": "{\\"type\\":\\"all\\"}",\n "sqlQueryId": "3dc0c45d-34d7-4b15-86c9-cdb2d3ebfc4e",\n "sqlReplaceTimeChunks": "all"\n },\n "granularity": {\n "type": "all"\n }\n }\n },\n "signature": [\n {\n "name": "__boost",\n "type": "LONG"\n },\n {\n "name": "agent_category",\n "type": "STRING"\n },\n {\n "name": "agent_type",\n "type": "STRING"\n },\n {\n "name": "timestamp",\n "type": "STRING"\n }\n ],\n "shuffleSpec": {\n "type": "targetSize",\n "clusterBy": {\n "columns": [\n {\n "columnName": "__boost"\n }\n ]\n },\n "targetSize": 3000000\n },\n "maxWorkerCount": 1,\n "shuffleCheckHasMultipleValues": true\n },\n "phase": "FINISHED",\n "workerCount": 1,\n "partitionCount": 1,\n "startTime": "2022-09-14T22:12:11.663Z",\n "duration": 19965,\n "sort": true\n },\n {\n "stageNumber": 1,\n "definition": {\n "id": "71ecb11e-09d7-42f8-9225-1662c8e7e121_1",\n "input": [\n {\n "type": "stage",\n "stage": 0\n }\n ],\n "processor": {\n "type": "segmentGenerator",\n "dataSchema": {\n "dataSource": "kttm_simple",\n "timestampSpec": {\n "column": "__time",\n "format": "millis",\n "missingValue": null\n },\n "dimensionsSpec": {\n "dimensions": [\n {\n "type": "string",\n "name": "timestamp",\n "multiValueHandling": "SORTED_ARRAY",\n "createBitmapIndex": true\n },\n {\n "type": "string",\n "name": "agent_category",\n "multiValueHandling": "SORTED_ARRAY",\n "createBitmapIndex": true\n },\n {\n "type": "string",\n "name": "agent_type",\n "multiValueHandling": "SORTED_ARRAY",\n "createBitmapIndex": true\n }\n ],\n "dimensionExclusions": [\n "__time"\n ],\n "includeAllDimensions": false\n },\n "metricsSpec": [],\n "granularitySpec": {\n "type": "arbitrary",\n "queryGranularity": {\n "type": "none"\n },\n "rollup": false,\n "intervals": [\n "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z"\n ]\n },\n "transformSpec": {\n "filter": null,\n "transforms": []\n }\n },\n "columnMappings": [\n {\n "queryColumn": "timestamp",\n "outputColumn": "timestamp"\n },\n {\n "queryColumn": "agent_category",\n "outputColumn": "agent_category"\n },\n {\n "queryColumn": "agent_type",\n "outputColumn": "agent_type"\n }\n ],\n "tuningConfig": {\n "maxNumWorkers": 1,\n "maxRowsInMemory": 100000,\n "rowsPerSegment": 3000000\n }\n },\n "signature": [],\n "maxWorkerCount": 1\n },\n "phase": "FINISHED",\n "workerCount": 1,\n "partitionCount": 1,\n "startTime": "2022-09-14T22:12:31.602Z",\n "duration": 5891\n }\n ],\n "counters": {\n "0": {\n "0": {\n "input0": {\n "type": "channel",\n "rows": [\n 465346\n ],\n "files": [\n 1\n ],\n "totalFiles": [\n 1\n ]\n },\n "output": {\n "type": "channel",\n "rows": [\n 465346\n ],\n "bytes": [\n 43694447\n ],\n "frames": [\n 7\n ]\n },\n "shuffle": {\n "type": "channel",\n "rows": [\n 465346\n ],\n "bytes": [\n 41835307\n ],\n "frames": [\n 73\n ]\n },\n "sortProgress": {\n "type": "sortProgress",\n "totalMergingLevels": 3,\n "levelToTotalBatches": {\n "0": 1,\n "1": 1,\n "2": 1\n },\n "levelToMergedBatches": {\n "0": 1,\n "1": 1,\n "2": 1\n },\n "totalMergersForUltimateLevel": 1,\n "progressDigest": 1\n }\n }\n },\n "1": {\n "0": {\n "input0": {\n "type": "channel",\n "rows": [\n 465346\n ],\n "bytes": [\n 41835307\n ],\n "frames": [\n 73\n ]\n },\n "segmentGenerationProgress": {\n "type": "segmentGenerationProgress",\n "rowsProcessed": 465346,\n "rowsPersisted": 465346,\n "rowsMerged": 465346\n }\n }\n }\n }\n }\n }\n}\n'))),(0,l.kt)("a",{name:"report-response-fields"}),(0,l.kt)("p",null,"The following table describes the response fields when you retrieve a report for a MSQ task engine using the ",(0,l.kt)("inlineCode",{parentName:"p"},"/druid/indexer/v1/task/{taskId}/reports")," endpoint:"),(0,l.kt)("table",null,(0,l.kt)("thead",{parentName:"table"},(0,l.kt)("tr",{parentName:"thead"},(0,l.kt)("th",{parentName:"tr",align:null},"Field"),(0,l.kt)("th",{parentName:"tr",align:null},"Description"))),(0,l.kt)("tbody",{parentName:"table"},(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.taskId")),(0,l.kt)("td",{parentName:"tr",align:null},"Controller task ID.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status")),(0,l.kt)("td",{parentName:"tr",align:null},"Query status container.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.status")),(0,l.kt)("td",{parentName:"tr",align:null},"RUNNING, SUCCESS, or FAILED.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.startTime")),(0,l.kt)("td",{parentName:"tr",align:null},"Start time of the query in ISO format. Only present if the query has started running.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.durationMs")),(0,l.kt)("td",{parentName:"tr",align:null},"Milliseconds elapsed after the query has started running. -1 denotes that the query hasn't started running yet.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.workers")),(0,l.kt)("td",{parentName:"tr",align:null},"Workers for the controller task.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.workers.<workerNumber>")),(0,l.kt)("td",{parentName:"tr",align:null},"Array of worker tasks including retries.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.workers.<workerNumber>[].workerId")),(0,l.kt)("td",{parentName:"tr",align:null},"Id of the worker task.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.workers.<workerNumber>[].status")),(0,l.kt)("td",{parentName:"tr",align:null},"RUNNING, SUCCESS, or FAILED.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.workers.<workerNumber>[].durationMs")),(0,l.kt)("td",{parentName:"tr",align:null},"Milliseconds elapsed between when the worker task was first requested and when it finished. It is -1 for worker tasks with status RUNNING.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.workers.<workerNumber>[].pendingMs")),(0,l.kt)("td",{parentName:"tr",align:null},"Milliseconds elapsed between when the worker task was first requested and when it fully started RUNNING. Actual work time can be calculated using ",(0,l.kt)("inlineCode",{parentName:"td"},"actualWorkTimeMS = durationMs - pendingMs"),".")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.pendingTasks")),(0,l.kt)("td",{parentName:"tr",align:null},"Number of tasks that are not fully started. -1 denotes that the number is currently unknown.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.runningTasks")),(0,l.kt)("td",{parentName:"tr",align:null},"Number of currently running tasks. Should be at least 1 since the controller is included.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.segmentLoadStatus")),(0,l.kt)("td",{parentName:"tr",align:null},"Segment loading container. Only present after the segments have been published.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.segmentLoadStatus.state")),(0,l.kt)("td",{parentName:"tr",align:null},"Either INIT, WAITING, SUCCESS, FAILED or TIMED_OUT.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.segmentLoadStatus.startTime")),(0,l.kt)("td",{parentName:"tr",align:null},"Time since which the controller has been waiting for the segments to finish loading.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.segmentLoadStatus.duration")),(0,l.kt)("td",{parentName:"tr",align:null},"The duration in milliseconds that the controller has been waiting for the segments to load.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.segmentLoadStatus.totalSegments")),(0,l.kt)("td",{parentName:"tr",align:null},"The total number of segments generated by the job. This includes tombstone segments (if any).")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.segmentLoadStatus.usedSegments")),(0,l.kt)("td",{parentName:"tr",align:null},"The number of segments which are marked as used based on the load rules. Unused segments can be cleaned up at any time.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.segmentLoadStatus.precachedSegments")),(0,l.kt)("td",{parentName:"tr",align:null},"The number of segments which are marked as precached and served by historicals, as per the load rules.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.segmentLoadStatus.onDemandSegments")),(0,l.kt)("td",{parentName:"tr",align:null},"The number of segments which are not loaded on any historical, as per the load rules.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.segmentLoadStatus.pendingSegments")),(0,l.kt)("td",{parentName:"tr",align:null},"The number of segments remaining to be loaded.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.segmentLoadStatus.unknownSegments")),(0,l.kt)("td",{parentName:"tr",align:null},"The number of segments whose status is unknown.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.segmentReport")),(0,l.kt)("td",{parentName:"tr",align:null},"Segment report. Only present if the query is an ingestion.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.segmentReport.shardSpec")),(0,l.kt)("td",{parentName:"tr",align:null},"Contains the shard spec chosen.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.segmentReport.details")),(0,l.kt)("td",{parentName:"tr",align:null},"Contains further reasoning about the shard spec chosen.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.errorReport")),(0,l.kt)("td",{parentName:"tr",align:null},"Error object. Only present if there was an error.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.errorReport.taskId")),(0,l.kt)("td",{parentName:"tr",align:null},"The task that reported the error, if known. May be a controller task or a worker task.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.errorReport.host")),(0,l.kt)("td",{parentName:"tr",align:null},"The hostname and port of the task that reported the error, if known.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.errorReport.stageNumber")),(0,l.kt)("td",{parentName:"tr",align:null},"The stage number that reported the error, if it happened during execution of a specific stage.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.errorReport.error")),(0,l.kt)("td",{parentName:"tr",align:null},"Error object. Contains ",(0,l.kt)("inlineCode",{parentName:"td"},"errorCode")," at a minimum, and may contain other fields as described in the ",(0,l.kt)("a",{parentName:"td",href:"/docs/latest/multi-stage-query/reference#error-codes"},"error code table"),". Always present if there is an error.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.errorReport.error.errorCode")),(0,l.kt)("td",{parentName:"tr",align:null},"One of the error codes from the ",(0,l.kt)("a",{parentName:"td",href:"/docs/latest/multi-stage-query/reference#error-codes"},"error code table"),". Always present if there is an error.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.errorReport.error.errorMessage")),(0,l.kt)("td",{parentName:"tr",align:null},"User-friendly error message. Not always present, even if there is an error.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.errorReport.exceptionStackTrace")),(0,l.kt)("td",{parentName:"tr",align:null},"Java stack trace in string form, if the error was due to a server-side exception.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages")),(0,l.kt)("td",{parentName:"tr",align:null},"Array of query stages.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].stageNumber")),(0,l.kt)("td",{parentName:"tr",align:null},"Each stage has a number that differentiates it from other stages.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].phase")),(0,l.kt)("td",{parentName:"tr",align:null},"Either NEW, READING_INPUT, POST_READING, RESULTS_COMPLETE, or FAILED. Only present if the stage has started.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].workerCount")),(0,l.kt)("td",{parentName:"tr",align:null},"Number of parallel tasks that this stage is running on. Only present if the stage has started.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].partitionCount")),(0,l.kt)("td",{parentName:"tr",align:null},"Number of output partitions generated by this stage. Only present if the stage has started and has computed its number of output partitions.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].startTime")),(0,l.kt)("td",{parentName:"tr",align:null},"Start time of this stage. Only present if the stage has started.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].duration")),(0,l.kt)("td",{parentName:"tr",align:null},"The number of milliseconds that the stage has been running. Only present if the stage has started.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].sort")),(0,l.kt)("td",{parentName:"tr",align:null},"A boolean that is set to ",(0,l.kt)("inlineCode",{parentName:"td"},"true")," if the stage does a sort as part of its execution.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].definition")),(0,l.kt)("td",{parentName:"tr",align:null},"The object defining what the stage does.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].definition.id")),(0,l.kt)("td",{parentName:"tr",align:null},"The unique identifier of the stage.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].definition.input")),(0,l.kt)("td",{parentName:"tr",align:null},"Array of inputs that the stage has.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].definition.broadcast")),(0,l.kt)("td",{parentName:"tr",align:null},"Array of input indexes that get broadcasted. Only present if there are inputs that get broadcasted.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].definition.processor")),(0,l.kt)("td",{parentName:"tr",align:null},"An object defining the processor logic.")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].definition.signature")),(0,l.kt)("td",{parentName:"tr",align:null},"The output signature of the stage.")))),(0,l.kt)("h2",{id:"cancel-a-query-task"},"Cancel a query task"),(0,l.kt)("p",null,"Cancels a query task.\nReturns a JSON object with the ID of the task that was canceled successfully."),(0,l.kt)("h3",{id:"url-3"},"URL"),(0,l.kt)("p",null,(0,l.kt)("inlineCode",{parentName:"p"},"POST")," ",(0,l.kt)("inlineCode",{parentName:"p"},"/druid/indexer/v1/task/{taskId}/shutdown")),(0,l.kt)("h3",{id:"responses-3"},"Responses"),(0,l.kt)(s.Z,{mdxType:"Tabs"},(0,l.kt)(i.Z,{value:"16",label:"200 SUCCESS",mdxType:"TabItem"},(0,l.kt)("br",null),(0,l.kt)("p",null,(0,l.kt)("em",{parentName:"p"},"Successfully shut down task"))),(0,l.kt)(i.Z,{value:"17",label:"404 NOT FOUND",mdxType:"TabItem"},(0,l.kt)("br",null),(0,l.kt)("p",null,(0,l.kt)("em",{parentName:"p"},"Cannot find task with ID or task is no longer running")))),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"sample-request-3"},"Sample request"),(0,l.kt)("p",null,"The following example shows how to cancel a query task with the ID ",(0,l.kt)("inlineCode",{parentName:"p"},"query-655efe33-781a-4c50-ae84-c2911b42d63c"),"."),(0,l.kt)(s.Z,{mdxType:"Tabs"},(0,l.kt)(i.Z,{value:"18",label:"HTTP",mdxType:"TabItem"},(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-HTTP"},"POST /druid/indexer/v1/task/query-655efe33-781a-4c50-ae84-c2911b42d63c/shutdown HTTP/1.1\nHost: http://ROUTER_IP:ROUTER_PORT\n"))),(0,l.kt)(i.Z,{value:"19",label:"cURL",mdxType:"TabItem"},(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-shell"},"curl --location --request POST 'http://ROUTER_IP:ROUTER_PORT/druid/indexer/v1/task/query-655efe33-781a-4c50-ae84-c2911b42d63c/shutdown'\n"))),(0,l.kt)(i.Z,{value:"20",label:"Python",mdxType:"TabItem"},(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-python"},"import requests\n\nurl = \"http://ROUTER_IP:ROUTER_PORT/druid/indexer/v1/task/query-655efe33-781a-4c50-ae84-c2911b42d63c/shutdown\"\n\npayload={}\nheaders = {}\n\nresponse = requests.post(url, headers=headers, data=payload, auth=('USER', 'PASSWORD'))\n\nprint(response.text)\n")))),(0,l.kt)("h3",{id:"sample-response-3"},"Sample response"),(0,l.kt)("p",null,"The response shows the ID of the task that was canceled."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-json"},'{\n "task": "query-655efe33-781a-4c50-ae84-c2911b42d63c"\n}\n')))}y.isMDXComponent=!0}}]);