blob: d2efd5276b93b00b6db7a711792d2f488c078e41 [file] [log] [blame]
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[6170],{3905:(e,t,n)=>{n.d(t,{Zo:()=>p,kt:()=>y});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 s(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 l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(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={},s=Object.keys(e);for(a=0;a<s.length;a++)n=s[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(a=0;a<s.length;a++)n=s[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):l(l({},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)}},g=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,s=e.originalType,o=e.parentName,p=i(e,["components","mdxType","originalType","parentName"]),d=u(n),g=r,y=d["".concat(o,".").concat(g)]||d[g]||m[g]||s;return n?a.createElement(y,l(l({ref:t},p),{},{components:n})):a.createElement(y,l({ref:t},p))}));function y(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var s=n.length,l=new Array(s);l[0]=g;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,l[1]=i;for(var u=2;u<s;u++)l[u]=n[u];return a.createElement.apply(null,l)}return a.createElement.apply(null,n)}g.displayName="MDXCreateElement"},85162:(e,t,n)=>{n.d(t,{Z:()=>l});var a=n(67294),r=n(86010);const s={tabItem:"tabItem_Ymn6"};function l(e){var t=e.children,n=e.hidden,l=e.className;return a.createElement("div",{role:"tabpanel",className:(0,r.Z)(s.tabItem,l),hidden:n},t)}},74866:(e,t,n)=>{n.d(t,{Z:()=>S});var a=n(87462),r=n(67294),s=n(86010),l=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 g(e){var t=e.value;return e.tabValues.some((function(e){return e.value===t}))}function y(e){var t=e.queryString,n=void 0!==t&&t,a=e.groupId,s=(0,i.k6)(),l=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)(l),(0,r.useCallback)((function(e){if(l){var t=new URLSearchParams(s.location.search);t.set(l,e),s.replace(Object.assign({},s.location,{search:t.toString()}))}}),[l,s])]}function c(e){var t,n,a,s,l=e.defaultValue,i=e.queryString,o=void 0!==i&&i,u=e.groupId,d=m(e),c=(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(!g({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:l,tabValues:d})})),k=c[0],h=c[1],N=y({queryString:o,groupId:u}),f=N[0],b=N[1],S=(t=function(e){return e?"docusaurus.tab."+e:null}({groupId:u}.groupId),n=(0,p.Nk)(t),a=n[0],s=n[1],[a,(0,r.useCallback)((function(e){t&&s.set(e)}),[t,s])]),T=S[0],v=S[1],w=function(){var e=null!=f?f:T;return g({value:e,tabValues:d})?e:null}();return(0,r.useLayoutEffect)((function(){w&&h(w)}),[w]),{selectedValue:k,selectValue:(0,r.useCallback)((function(e){if(!g({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 k=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,l.o5)().blockElementScrollPositionUntilNextRender,m=function(e){var t=e.currentTarget,n=p.indexOf(t),a=u[n].value;a!==i&&(d(t),o(a))},g=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 s,l=p.indexOf(e.currentTarget)-1;n=null!=(s=p[l])?s:p[p.length-1]}null==(t=n)||t.focus()};return r.createElement("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,s.Z)("tabs",{"tabs--block":n},t)},u.map((function(e){var t=e.value,n=e.label,l=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:g,onClick:m},l,{className:(0,s.Z)("tabs__item",h.tabItem,null==l?void 0:l.className,{"tabs__item--active":i===t})}),null!=n?n:t)})))}function f(e){var t=e.lazy,n=e.children,a=e.selectedValue,s=(Array.isArray(n)?n:[n]).filter(Boolean);if(t){var l=s.find((function(e){return e.props.value===a}));return l?(0,r.cloneElement)(l,{className:"margin-top--md"}):null}return r.createElement("div",{className:"margin-top--md"},s.map((function(e,t){return(0,r.cloneElement)(e,{key:t,hidden:e.props.value!==a})})))}function b(e){var t=c(e);return r.createElement("div",{className:(0,s.Z)("tabs-container",h.tabList)},r.createElement(N,(0,a.Z)({},e,t)),r.createElement(f,(0,a.Z)({},e,t)))}function S(e){var t=(0,k.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:()=>k,frontMatter:()=>u,metadata:()=>d,toc:()=>g});var a=n(87462),r=n(63366),s=(n(67294),n(3905)),l=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={},g=[{value:"Submit a query",id:"submit-a-query",level:2},{value:"Request",id:"request",level:4},{value:"Response",id:"response",level:4},{value:"Get the status for a query task",id:"get-the-status-for-a-query-task",level:2},{value:"Request",id:"request-1",level:4},{value:"Response",id:"response-1",level:4},{value:"Get the report for a query task",id:"get-the-report-for-a-query-task",level:2},{value:"Request",id:"request-2",level:4},{value:"Response",id:"response-2",level:4},{value:"Cancel a query task",id:"cancel-a-query-task",level:2},{value:"Request",id:"request-3",level:4},{value:"Response",id:"response-3",level:4}],y={toc:g},c="wrapper";function k(e){var t=e.components,n=(0,r.Z)(e,o);return(0,s.kt)(c,(0,a.Z)({},y,n,{components:t,mdxType:"MDXLayout"}),(0,s.kt)("admonition",{type:"info"},(0,s.kt)("p",{parentName:"admonition"}," This page describes SQL-based batch ingestion using the ",(0,s.kt)("a",{parentName:"p",href:"/docs/latest/multi-stage-query/"},(0,s.kt)("inlineCode",{parentName:"a"},"druid-multi-stage-query")),"\nextension, new in Druid 24.0. Refer to the ",(0,s.kt)("a",{parentName:"p",href:"/docs/latest/ingestion/#batch"},"ingestion methods")," table to determine which\ningestion method is right for you.")),(0,s.kt)("p",null,"The ",(0,s.kt)("strong",{parentName:"p"},"Query")," view in the web console provides a friendly experience for the multi-stage query task engine (MSQ task\nengine) and multi-stage query architecture. We recommend using the web console if you do not need a programmatic\ninterface."),(0,s.kt)("p",null,"When using the API for the MSQ task engine, the action you want to take determines the endpoint you use:"),(0,s.kt)("ul",null,(0,s.kt)("li",{parentName:"ul"},(0,s.kt)("inlineCode",{parentName:"li"},"/druid/v2/sql/task")," endpoint: Submit a query for ingestion."),(0,s.kt)("li",{parentName:"ul"},(0,s.kt)("inlineCode",{parentName:"li"},"/druid/indexer/v1/task")," endpoint: Interact with a query, including getting its status, getting its details, or canceling it. 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,s.kt)("a",{parentName:"li",href:"/docs/latest/ingestion/tasks"},"API reference for Druid"),".")),(0,s.kt)("h2",{id:"submit-a-query"},"Submit a query"),(0,s.kt)("p",null,"You submit queries to the MSQ task engine using the ",(0,s.kt)("inlineCode",{parentName:"p"},"POST /druid/v2/sql/task/")," endpoint."),(0,s.kt)("h4",{id:"request"},"Request"),(0,s.kt)("p",null,"The SQL task endpoint accepts ",(0,s.kt)("a",{parentName:"p",href:"/docs/latest/api-reference/sql-api#request-body"},"SQL requests in the JSON-over-HTTP form")," using the\n",(0,s.kt)("inlineCode",{parentName:"p"},"query"),", ",(0,s.kt)("inlineCode",{parentName:"p"},"context"),", and ",(0,s.kt)("inlineCode",{parentName:"p"},"parameters")," fields, but ignoring the ",(0,s.kt)("inlineCode",{parentName:"p"},"resultFormat"),", ",(0,s.kt)("inlineCode",{parentName:"p"},"header"),", ",(0,s.kt)("inlineCode",{parentName:"p"},"typesHeader"),", and\n",(0,s.kt)("inlineCode",{parentName:"p"},"sqlTypesHeader")," fields."),(0,s.kt)("p",null,"This endpoint accepts ",(0,s.kt)("a",{parentName:"p",href:"/docs/latest/multi-stage-query/reference#insert"},"INSERT")," and ",(0,s.kt)("a",{parentName:"p",href:"/docs/latest/multi-stage-query/reference#replace"},"REPLACE")," statements."),(0,s.kt)("p",null,"As an experimental feature, this endpoint also accepts SELECT queries. SELECT query results are collected from workers\nby the controller, and written into the ",(0,s.kt)("a",{parentName:"p",href:"#get-the-report-for-a-query-task"},"task report")," as an array of arrays. The\nbehavior and result format of plain SELECT queries (without INSERT or REPLACE) is subject to change."),(0,s.kt)(l.Z,{mdxType:"Tabs"},(0,s.kt)(i.Z,{value:"1",label:"HTTP",mdxType:"TabItem"},(0,s.kt)("pre",null,(0,s.kt)("code",{parentName:"pre"},"POST /druid/v2/sql/task\n")),(0,s.kt)("pre",null,(0,s.kt)("code",{parentName:"pre",className:"language-json"},'{\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,s.kt)(i.Z,{value:"2",label:"curl",mdxType:"TabItem"},(0,s.kt)("pre",null,(0,s.kt)("code",{parentName:"pre",className:"language-bash"},'# Make sure you replace `username`, `password`, `your-instance`, and `port` with the values for your deployment.\ncurl --location --request POST \'https://<username>:<password>@<your-instance>:<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,s.kt)(i.Z,{value:"3",label:"Python",mdxType:"TabItem"},(0,s.kt)("pre",null,(0,s.kt)("code",{parentName:"pre",className:"language-python"},'import json\nimport requests\n\n# Make sure you replace `your-instance`, and `port` with the values for your deployment.\nurl = "https://<your-instance>:<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,s.kt)("h4",{id:"response"},"Response"),(0,s.kt)("pre",null,(0,s.kt)("code",{parentName:"pre",className:"language-json"},'{\n "taskId": "query-f795a235-4dc7-4fef-abac-3ae3f9686b79",\n "state": "RUNNING",\n}\n')),(0,s.kt)("p",null,(0,s.kt)("strong",{parentName:"p"},"Response fields")),(0,s.kt)("table",null,(0,s.kt)("thead",{parentName:"table"},(0,s.kt)("tr",{parentName:"thead"},(0,s.kt)("th",{parentName:"tr",align:null},"Field"),(0,s.kt)("th",{parentName:"tr",align:null},"Description"))),(0,s.kt)("tbody",{parentName:"table"},(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"taskId")),(0,s.kt)("td",{parentName:"tr",align:null},"Controller task ID. You can use Druid's standard ",(0,s.kt)("a",{parentName:"td",href:"/docs/latest/api-reference/tasks-api"},"Tasks API")," to interact with this controller task.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"state")),(0,s.kt)("td",{parentName:"tr",align:null},'Initial state for the query, which is "RUNNING".')))),(0,s.kt)("h2",{id:"get-the-status-for-a-query-task"},"Get the status for a query task"),(0,s.kt)("p",null,"You can retrieve status of a query to see if it is still running, completed successfully, failed, or got canceled."),(0,s.kt)("h4",{id:"request-1"},"Request"),(0,s.kt)(l.Z,{mdxType:"Tabs"},(0,s.kt)(i.Z,{value:"4",label:"HTTP",mdxType:"TabItem"},(0,s.kt)("pre",null,(0,s.kt)("code",{parentName:"pre"},"GET /druid/indexer/v1/task/<taskId>/status\n"))),(0,s.kt)(i.Z,{value:"5",label:"curl",mdxType:"TabItem"},(0,s.kt)("pre",null,(0,s.kt)("code",{parentName:"pre",className:"language-bash"},"# Make sure you replace `username`, `password`, `your-instance`, `port`, and `taskId` with the values for your deployment.\ncurl --location --request GET 'https://<username>:<password>@<your-instance>:<port>/druid/indexer/v1/task/<taskId>/status'\n"))),(0,s.kt)(i.Z,{value:"6",label:"Python",mdxType:"TabItem"},(0,s.kt)("pre",null,(0,s.kt)("code",{parentName:"pre",className:"language-python"},"import requests\n\n# Make sure you replace `your-instance`, `port`, and `taskId` with the values for your deployment.\nurl = \"https://<your-instance>:<port>/druid/indexer/v1/task/<taskId>/status\"\n\npayload={}\nheaders = {}\n\nresponse = requests.get(url, headers=headers, data=payload, auth=('USER', 'PASSWORD'))\n\nprint(response.text)\n")))),(0,s.kt)("h4",{id:"response-1"},"Response"),(0,s.kt)("pre",null,(0,s.kt)("code",{parentName:"pre"},'{\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,s.kt)("h2",{id:"get-the-report-for-a-query-task"},"Get the report for a query task"),(0,s.kt)("p",null,"A report provides detailed information about a query task, including things like the stages, warnings, and errors."),(0,s.kt)("p",null,"Keep the following in mind when using the task API to view reports:"),(0,s.kt)("ul",null,(0,s.kt)("li",{parentName:"ul"},"The task report for an entire job is associated with the ",(0,s.kt)("inlineCode",{parentName:"li"},"query_controller")," task. The ",(0,s.kt)("inlineCode",{parentName:"li"},"query_worker")," tasks do not have\ntheir own reports; their information is incorporated into the controller report."),(0,s.kt)("li",{parentName:"ul"},"The task report API may report ",(0,s.kt)("inlineCode",{parentName:"li"},"404 Not Found")," temporarily while the task is in the process of starting up."),(0,s.kt)("li",{parentName:"ul"},"As an experimental feature, the MSQ task engine supports running SELECT queries. SELECT query results are written into\nthe ",(0,s.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,s.kt)("li",{parentName:"ul"},(0,s.kt)("inlineCode",{parentName:"li"},"multiStageQuery.payload.results.resultsTruncated")," denote whether the results of the report have been truncated to prevent\nthe reports from blowing up")),(0,s.kt)("p",null,"For an explanation of the fields in a report, see ",(0,s.kt)("a",{parentName:"p",href:"#report-response-fields"},"Report response fields"),"."),(0,s.kt)("h4",{id:"request-2"},"Request"),(0,s.kt)(l.Z,{mdxType:"Tabs"},(0,s.kt)(i.Z,{value:"7",label:"HTTP",mdxType:"TabItem"},(0,s.kt)("pre",null,(0,s.kt)("code",{parentName:"pre"},"GET /druid/indexer/v1/task/<taskId>/reports\n"))),(0,s.kt)(i.Z,{value:"8",label:"curl",mdxType:"TabItem"},(0,s.kt)("pre",null,(0,s.kt)("code",{parentName:"pre",className:"language-bash"},"# Make sure you replace `username`, `password`, `your-instance`, `port`, and `taskId` with the values for your deployment.\ncurl --location --request GET 'https://<username>:<password>@<your-instance>:<port>/druid/indexer/v1/task/<taskId>/reports'\n"))),(0,s.kt)(i.Z,{value:"9",label:"Python",mdxType:"TabItem"},(0,s.kt)("pre",null,(0,s.kt)("code",{parentName:"pre",className:"language-python"},"import requests\n\n# Make sure you replace `your-instance`, `port`, and `taskId` with the values for your deployment.\nurl = \"https://<your-instance>:<port>/druid/indexer/v1/task/<taskId>/reports\"\n\nheaders = {}\nresponse = requests.get(url, headers=headers, auth=('USER', 'PASSWORD'))\nprint(response.text)\n")))),(0,s.kt)("h4",{id:"response-2"},"Response"),(0,s.kt)("p",null,"The response shows an example report for a query."),(0,s.kt)("details",null,(0,s.kt)("summary",null,"Show the response"),(0,s.kt)("pre",null,(0,s.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 "pendingTasks": 0,\n "runningTasks": 2,\n "segmentLoadStatus": {\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 },\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,s.kt)("a",{name:"report-response-fields"}),(0,s.kt)("p",null,"The following table describes the response fields when you retrieve a report for a MSQ task engine using the ",(0,s.kt)("inlineCode",{parentName:"p"},"/druid/indexer/v1/task/<taskId>/reports")," endpoint:"),(0,s.kt)("table",null,(0,s.kt)("thead",{parentName:"table"},(0,s.kt)("tr",{parentName:"thead"},(0,s.kt)("th",{parentName:"tr",align:null},"Field"),(0,s.kt)("th",{parentName:"tr",align:null},"Description"))),(0,s.kt)("tbody",{parentName:"table"},(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.taskId")),(0,s.kt)("td",{parentName:"tr",align:null},"Controller task ID.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status")),(0,s.kt)("td",{parentName:"tr",align:null},"Query status container.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.status")),(0,s.kt)("td",{parentName:"tr",align:null},"RUNNING, SUCCESS, or FAILED.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.startTime")),(0,s.kt)("td",{parentName:"tr",align:null},"Start time of the query in ISO format. Only present if the query has started running.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.durationMs")),(0,s.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,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.workers")),(0,s.kt)("td",{parentName:"tr",align:null},"Workers for the controller task.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.workers.<workerNumber>")),(0,s.kt)("td",{parentName:"tr",align:null},"Array of worker tasks including retries.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.workers.<workerNumber>[].workerId")),(0,s.kt)("td",{parentName:"tr",align:null},"Id of the worker task.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.workers.<workerNumber>[].status")),(0,s.kt)("td",{parentName:"tr",align:null},"RUNNING, SUCCESS, or FAILED.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.workers.<workerNumber>[].durationMs")),(0,s.kt)("td",{parentName:"tr",align:null},"Milliseconds elapsed after the worker task started running. It is -1 for worker tasks with status RUNNING.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.pendingTasks")),(0,s.kt)("td",{parentName:"tr",align:null},"Number of tasks that are not fully started. -1 denotes that the number is currently unknown.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.runningTasks")),(0,s.kt)("td",{parentName:"tr",align:null},"Number of currently running tasks. Should be at least 1 since the controller is included.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.segmentLoadStatus")),(0,s.kt)("td",{parentName:"tr",align:null},"Segment loading container. Only present after the segments have been published.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.segmentLoadStatus.state")),(0,s.kt)("td",{parentName:"tr",align:null},"Either INIT, WAITING, SUCCESS, FAILED or TIMED_OUT.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.segmentLoadStatus.startTime")),(0,s.kt)("td",{parentName:"tr",align:null},"Time since which the controller has been waiting for the segments to finish loading.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.segmentLoadStatus.duration")),(0,s.kt)("td",{parentName:"tr",align:null},"The duration in milliseconds that the controller has been waiting for the segments to load.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.segmentLoadStatus.totalSegments")),(0,s.kt)("td",{parentName:"tr",align:null},"The total number of segments generated by the job. This includes tombstone segments (if any).")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.segmentLoadStatus.usedSegments")),(0,s.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,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.segmentLoadStatus.precachedSegments")),(0,s.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,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.segmentLoadStatus.onDemandSegments")),(0,s.kt)("td",{parentName:"tr",align:null},"The number of segments which are not loaded on any historical, as per the load rules.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.segmentLoadStatus.pendingSegments")),(0,s.kt)("td",{parentName:"tr",align:null},"The number of segments remaining to be loaded.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.segmentLoadStatus.unknownSegments")),(0,s.kt)("td",{parentName:"tr",align:null},"The number of segments whose status is unknown.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.errorReport")),(0,s.kt)("td",{parentName:"tr",align:null},"Error object. Only present if there was an error.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.errorReport.taskId")),(0,s.kt)("td",{parentName:"tr",align:null},"The task that reported the error, if known. May be a controller task or a worker task.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.errorReport.host")),(0,s.kt)("td",{parentName:"tr",align:null},"The hostname and port of the task that reported the error, if known.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.errorReport.stageNumber")),(0,s.kt)("td",{parentName:"tr",align:null},"The stage number that reported the error, if it happened during execution of a specific stage.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.errorReport.error")),(0,s.kt)("td",{parentName:"tr",align:null},"Error object. Contains ",(0,s.kt)("inlineCode",{parentName:"td"},"errorCode")," at a minimum, and may contain other fields as described in the ",(0,s.kt)("a",{parentName:"td",href:"/docs/latest/multi-stage-query/reference#error-codes"},"error code table"),". Always present if there is an error.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.errorReport.error.errorCode")),(0,s.kt)("td",{parentName:"tr",align:null},"One of the error codes from the ",(0,s.kt)("a",{parentName:"td",href:"/docs/latest/multi-stage-query/reference#error-codes"},"error code table"),". Always present if there is an error.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.errorReport.error.errorMessage")),(0,s.kt)("td",{parentName:"tr",align:null},"User-friendly error message. Not always present, even if there is an error.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.status.errorReport.exceptionStackTrace")),(0,s.kt)("td",{parentName:"tr",align:null},"Java stack trace in string form, if the error was due to a server-side exception.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages")),(0,s.kt)("td",{parentName:"tr",align:null},"Array of query stages.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].stageNumber")),(0,s.kt)("td",{parentName:"tr",align:null},"Each stage has a number that differentiates it from other stages.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].phase")),(0,s.kt)("td",{parentName:"tr",align:null},"Either NEW, READING_INPUT, POST_READING, RESULTS_COMPLETE, or FAILED. Only present if the stage has started.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].workerCount")),(0,s.kt)("td",{parentName:"tr",align:null},"Number of parallel tasks that this stage is running on. Only present if the stage has started.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].partitionCount")),(0,s.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,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].startTime")),(0,s.kt)("td",{parentName:"tr",align:null},"Start time of this stage. Only present if the stage has started.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].duration")),(0,s.kt)("td",{parentName:"tr",align:null},"The number of milliseconds that the stage has been running. Only present if the stage has started.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].sort")),(0,s.kt)("td",{parentName:"tr",align:null},"A boolean that is set to ",(0,s.kt)("inlineCode",{parentName:"td"},"true")," if the stage does a sort as part of its execution.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].definition")),(0,s.kt)("td",{parentName:"tr",align:null},"The object defining what the stage does.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].definition.id")),(0,s.kt)("td",{parentName:"tr",align:null},"The unique identifier of the stage.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].definition.input")),(0,s.kt)("td",{parentName:"tr",align:null},"Array of inputs that the stage has.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].definition.broadcast")),(0,s.kt)("td",{parentName:"tr",align:null},"Array of input indexes that get broadcasted. Only present if there are inputs that get broadcasted.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].definition.processor")),(0,s.kt)("td",{parentName:"tr",align:null},"An object defining the processor logic.")),(0,s.kt)("tr",{parentName:"tbody"},(0,s.kt)("td",{parentName:"tr",align:null},(0,s.kt)("inlineCode",{parentName:"td"},"multiStageQuery.payload.stages[].definition.signature")),(0,s.kt)("td",{parentName:"tr",align:null},"The output signature of the stage.")))),(0,s.kt)("h2",{id:"cancel-a-query-task"},"Cancel a query task"),(0,s.kt)("h4",{id:"request-3"},"Request"),(0,s.kt)(l.Z,{mdxType:"Tabs"},(0,s.kt)(i.Z,{value:"10",label:"HTTP",mdxType:"TabItem"},(0,s.kt)("pre",null,(0,s.kt)("code",{parentName:"pre"},"POST /druid/indexer/v1/task/<taskId>/shutdown\n"))),(0,s.kt)(i.Z,{value:"11",label:"curl",mdxType:"TabItem"},(0,s.kt)("pre",null,(0,s.kt)("code",{parentName:"pre",className:"language-bash"},"# Make sure you replace `username`, `password`, `your-instance`, `port`, and `taskId` with the values for your deployment.\ncurl --location --request POST 'https://<username>:<password>@<your-instance>:<port>/druid/indexer/v1/task/<taskId>/shutdown'\n"))),(0,s.kt)(i.Z,{value:"12",label:"Python",mdxType:"TabItem"},(0,s.kt)("pre",null,(0,s.kt)("code",{parentName:"pre",className:"language-python"},"import requests\n\n# Make sure you replace `your-instance`, `port`, and `taskId` with the values for your deployment.\nurl = \"https://<your-instance>:<port>/druid/indexer/v1/task/<taskId>/shutdown\"\n\npayload={}\nheaders = {}\n\nresponse = requests.post(url, headers=headers, data=payload, auth=('USER', 'PASSWORD'))\n\nprint(response.text)\n")))),(0,s.kt)("h4",{id:"response-3"},"Response"),(0,s.kt)("pre",null,(0,s.kt)("code",{parentName:"pre"},'{\n "task": "query-655efe33-781a-4c50-ae84-c2911b42d63c"\n}\n')))}k.isMDXComponent=!0}}]);