blob: 1f97e8966c041c29cbf27972d785e22e11771e60 [file] [log] [blame]
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[3996],{3905:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>g});var o=n(7294);function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function s(e,t){if(null==e)return{};var n,o,a=function(e,t){if(null==e)return{};var n,o,a={},r=Object.keys(e);for(o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var p=o.createContext({}),l=function(e){var t=o.useContext(p),n=t;return e&&(n="function"==typeof e?e(t):i(i({},t),e)),n},c=function(e){var t=l(e.components);return o.createElement(p.Provider,{value:t},e.children)},m="mdxType",u={inlineCode:"code",wrapper:function(e){var t=e.children;return o.createElement(o.Fragment,{},t)}},d=o.forwardRef((function(e,t){var n=e.components,a=e.mdxType,r=e.originalType,p=e.parentName,c=s(e,["components","mdxType","originalType","parentName"]),m=l(n),d=a,g=m["".concat(p,".").concat(d)]||m[d]||u[d]||r;return n?o.createElement(g,i(i({ref:t},c),{},{components:n})):o.createElement(g,i({ref:t},c))}));function g(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var r=n.length,i=new Array(r);i[0]=d;var s={};for(var p in t)hasOwnProperty.call(t,p)&&(s[p]=t[p]);s.originalType=e,s[m]="string"==typeof e?e:a,i[1]=s;for(var l=2;l<r;l++)i[l]=n[l];return o.createElement.apply(null,i)}return o.createElement.apply(null,n)}d.displayName="MDXCreateElement"},2567:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>p,default:()=>g,frontMatter:()=>s,metadata:()=>l,toc:()=>m});var o=n(7462),a=n(3366),r=(n(7294),n(3905)),i=["components"],s={id:"tutorial-msq-convert-spec",title:"Tutorial: Convert an ingestion spec for SQL-based ingestion",sidebar_label:"Convert ingestion spec to SQL",description:"How to convert an ingestion spec to a query for SQL-based ingestion in the web console."},p=void 0,l={unversionedId:"tutorials/tutorial-msq-convert-spec",id:"tutorials/tutorial-msq-convert-spec",title:"Tutorial: Convert an ingestion spec for SQL-based ingestion",description:"How to convert an ingestion spec to a query for SQL-based ingestion in the web console.",source:"@site/docs/26.0.0/tutorials/tutorial-msq-convert-spec.md",sourceDirName:"tutorials",slug:"/tutorials/tutorial-msq-convert-spec",permalink:"/docs/26.0.0/tutorials/tutorial-msq-convert-spec",draft:!1,tags:[],version:"current",frontMatter:{id:"tutorial-msq-convert-spec",title:"Tutorial: Convert an ingestion spec for SQL-based ingestion",sidebar_label:"Convert ingestion spec to SQL",description:"How to convert an ingestion spec to a query for SQL-based ingestion in the web console."},sidebar:"docs",previous:{title:"Kerberized HDFS deep storage",permalink:"/docs/26.0.0/tutorials/tutorial-kerberos-hadoop"},next:{title:"Get to know Query view",permalink:"/docs/26.0.0/tutorials/tutorial-sql-query-view"}},c={},m=[],u={toc:m},d="wrapper";function g(e){var t=e.components,s=(0,a.Z)(e,i);return(0,r.kt)(d,(0,o.Z)({},u,s,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("blockquote",null,(0,r.kt)("p",{parentName:"blockquote"},"This page describes SQL-based batch ingestion using the ",(0,r.kt)("a",{parentName:"p",href:"/docs/26.0.0/multi-stage-query/"},(0,r.kt)("inlineCode",{parentName:"a"},"druid-multi-stage-query")),"\nextension, new in Druid 24.0. Refer to the ",(0,r.kt)("a",{parentName:"p",href:"/docs/26.0.0/ingestion/#batch"},"ingestion methods")," table to determine which\ningestion method is right for you.")),(0,r.kt)("p",null,"If you're already ingesting data with ",(0,r.kt)("a",{parentName:"p",href:"/docs/26.0.0/ingestion/native-batch"},"native batch ingestion"),", you can use the ",(0,r.kt)("a",{parentName:"p",href:"/docs/26.0.0/operations/web-console"},"web console")," to convert the ingestion spec to a SQL query that the multi-stage query task engine can use to ingest data."),(0,r.kt)("p",null,"This tutorial demonstrates how to convert the ingestion spec to a query task in the web console."),(0,r.kt)("p",null,"To convert the ingestion spec to a query task, do the following:"),(0,r.kt)("ol",null,(0,r.kt)("li",{parentName:"ol"},(0,r.kt)("p",{parentName:"li"},"In the ",(0,r.kt)("strong",{parentName:"p"},"Query")," view of the web console, navigate to the menu bar that includes ",(0,r.kt)("strong",{parentName:"p"},"Run"),".")),(0,r.kt)("li",{parentName:"ol"},(0,r.kt)("p",{parentName:"li"},"Click the ellipsis icon and select ",(0,r.kt)("strong",{parentName:"p"},"Convert ingestion spec to SQL"),".\n",(0,r.kt)("img",{alt:"Convert ingestion spec to SQL",src:n(49).Z,title:"Convert ingestion spec to SQL",width:"1250",height:"640"}))),(0,r.kt)("li",{parentName:"ol"},(0,r.kt)("p",{parentName:"li"},"In the ",(0,r.kt)("strong",{parentName:"p"},"Ingestion spec to covert")," window, insert your ingestion spec. You can use your own spec or the sample ingestion spec provided in the tutorial. The sample spec uses data hosted at ",(0,r.kt)("inlineCode",{parentName:"p"},"https://druid.apache.org/data/wikipedia.json.gz")," and loads it into a table named ",(0,r.kt)("inlineCode",{parentName:"p"},"wikipedia"),":"),(0,r.kt)("details",null,(0,r.kt)("summary",null,"Show the spec"),(0,r.kt)("pre",{parentName:"li"},(0,r.kt)("code",{parentName:"pre",className:"language-json"},'{\n "type": "index_parallel",\n "spec": {\n "ioConfig": {\n "type": "index_parallel",\n "inputSource": {\n "type": "http",\n "uris": [\n "https://druid.apache.org/data/wikipedia.json.gz"\n ]\n },\n "inputFormat": {\n "type": "json"\n }\n },\n "tuningConfig": {\n "type": "index_parallel",\n "partitionsSpec": {\n "type": "dynamic"\n }\n },\n "dataSchema": {\n "dataSource": "wikipedia",\n "timestampSpec": {\n "column": "timestamp",\n "format": "iso"\n },\n "dimensionsSpec": {\n "dimensions": [\n "isRobot",\n "channel",\n "flags",\n "isUnpatrolled",\n "page",\n "diffUrl",\n {\n "type": "long",\n "name": "added"\n },\n "comment",\n {\n "type": "long",\n "name": "commentLength"\n },\n "isNew",\n "isMinor",\n {\n "type": "long",\n "name": "delta"\n },\n "isAnonymous",\n "user",\n {\n "type": "long",\n "name": "deltaBucket"\n },\n {\n "type": "long",\n "name": "deleted"\n },\n "namespace",\n "cityName",\n "countryName",\n "regionIsoCode",\n "metroCode",\n "countryIsoCode",\n "regionName"\n ]\n },\n "granularitySpec": {\n "queryGranularity": "none",\n "rollup": false,\n "segmentGranularity": "day"\n }\n }\n }\n}\n')))),(0,r.kt)("li",{parentName:"ol"},(0,r.kt)("p",{parentName:"li"},"Click ",(0,r.kt)("strong",{parentName:"p"},"Submit")," to submit the spec. The web console uses the JSON-based ingestion spec to generate a SQL query that you can use instead. This is what the query looks like for the sample ingestion spec:"),(0,r.kt)("details",null,(0,r.kt)("summary",null,"Show the query"),(0,r.kt)("pre",{parentName:"li"},(0,r.kt)("code",{parentName:"pre",className:"language-sql"},'-- This SQL query was auto generated from an ingestion spec\nREPLACE INTO wikipedia OVERWRITE ALL\nWITH source AS (SELECT * FROM TABLE(\n EXTERN(\n \'{"type":"http","uris":["https://druid.apache.org/data/wikipedia.json.gz"]}\',\n \'{"type":"json"}\',\n \'[{"name":"timestamp","type":"string"},{"name":"isRobot","type":"string"},{"name":"channel","type":"string"},{"name":"flags","type":"string"},{"name":"isUnpatrolled","type":"string"},{"name":"page","type":"string"},{"name":"diffUrl","type":"string"},{"name":"added","type":"long"},{"name":"comment","type":"string"},{"name":"commentLength","type":"long"},{"name":"isNew","type":"string"},{"name":"isMinor","type":"string"},{"name":"delta","type":"long"},{"name":"isAnonymous","type":"string"},{"name":"user","type":"string"},{"name":"deltaBucket","type":"long"},{"name":"deleted","type":"long"},{"name":"namespace","type":"string"},{"name":"cityName","type":"string"},{"name":"countryName","type":"string"},{"name":"regionIsoCode","type":"string"},{"name":"metroCode","type":"string"},{"name":"countryIsoCode","type":"string"},{"name":"regionName","type":"string"}]\'\n )\n))\nSELECT\n TIME_PARSE("timestamp") AS __time,\n "isRobot",\n "channel",\n "flags",\n "isUnpatrolled",\n "page",\n "diffUrl",\n "added",\n "comment",\n "commentLength",\n "isNew",\n "isMinor",\n "delta",\n "isAnonymous",\n "user",\n "deltaBucket",\n "deleted",\n "namespace",\n "cityName",\n "countryName",\n "regionIsoCode",\n "metroCode",\n "countryIsoCode",\n "regionName"\nFROM source\nPARTITIONED BY DAY\n')))),(0,r.kt)("li",{parentName:"ol"},(0,r.kt)("p",{parentName:"li"},"Review the generated SQL query to make sure it matches your requirements and does what you expect.")),(0,r.kt)("li",{parentName:"ol"},(0,r.kt)("p",{parentName:"li"},"Click ",(0,r.kt)("strong",{parentName:"p"},"Run")," to start the ingestion."))))}g.isMDXComponent=!0},49:(e,t,n)=>{n.d(t,{Z:()=>o});const o=n.p+"assets/images/tutorial-msq-convert-3042e5d3f5b8888781ad4d07c246e42a.png"}}]);