blob: 8f346ad041e728391d225d63b695554042b56b8e [file] [log] [blame]
"use strict";(self.webpackChunkdoris_website=self.webpackChunkdoris_website||[]).push([[41010],{15680:(e,n,r)=>{r.d(n,{xA:()=>u,yg:()=>p});var t=r(296540);function a(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function i(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),r.push.apply(r,t)}return r}function l(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?i(Object(r),!0).forEach((function(n){a(e,n,r[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))}))}return e}function o(e,n){if(null==e)return{};var r,t,a=function(e,n){if(null==e)return{};var r,t,a={},i=Object.keys(e);for(t=0;t<i.length;t++)r=i[t],n.indexOf(r)>=0||(a[r]=e[r]);return a}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(t=0;t<i.length;t++)r=i[t],n.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}var c=t.createContext({}),s=function(e){var n=t.useContext(c),r=n;return e&&(r="function"==typeof e?e(n):l(l({},n),e)),r},u=function(e){var n=s(e.components);return t.createElement(c.Provider,{value:n},e.children)},f="mdxType",y={inlineCode:"code",wrapper:function(e){var n=e.children;return t.createElement(t.Fragment,{},n)}},d=t.forwardRef((function(e,n){var r=e.components,a=e.mdxType,i=e.originalType,c=e.parentName,u=o(e,["components","mdxType","originalType","parentName"]),f=s(r),d=a,p=f["".concat(c,".").concat(d)]||f[d]||y[d]||i;return r?t.createElement(p,l(l({ref:n},u),{},{components:r})):t.createElement(p,l({ref:n},u))}));function p(e,n){var r=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var i=r.length,l=new Array(i);l[0]=d;var o={};for(var c in n)hasOwnProperty.call(n,c)&&(o[c]=n[c]);o.originalType=e,o[f]="string"==typeof e?e:a,l[1]=o;for(var s=2;s<i;s++)l[s]=r[s];return t.createElement.apply(null,l)}return t.createElement.apply(null,r)}d.displayName="MDXCreateElement"},741048:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>c,contentTitle:()=>l,default:()=>y,frontMatter:()=>i,metadata:()=>o,toc:()=>s});var t=r(58168),a=(r(296540),r(15680));const i={title:"ARRAY_DIFFERENCE",language:"en"},l=void 0,o={unversionedId:"sql-manual/sql-functions/array-functions/array-difference",id:"sql-manual/sql-functions/array-functions/array-difference",title:"ARRAY_DIFFERENCE",description:"\x3c!--",source:"@site/docs/sql-manual/sql-functions/array-functions/array-difference.md",sourceDirName:"sql-manual/sql-functions/array-functions",slug:"/sql-manual/sql-functions/array-functions/array-difference",permalink:"/docs/dev/sql-manual/sql-functions/array-functions/array-difference",draft:!1,tags:[],version:"current",frontMatter:{title:"ARRAY_DIFFERENCE",language:"en"},sidebar:"docs",previous:{title:"ARRAY_DISTINCT",permalink:"/docs/dev/sql-manual/sql-functions/array-functions/array-distinct"},next:{title:"ARRAY_UNION",permalink:"/docs/dev/sql-manual/sql-functions/array-functions/array-union"}},c={},s=[{value:"array_difference",id:"array_difference",level:2},{value:"description",id:"description",level:3},{value:"Syntax",id:"syntax",level:4},{value:"notice",id:"notice",level:3},{value:"example",id:"example",level:3},{value:"keywords",id:"keywords",level:3}],u={toc:s},f="wrapper";function y(e){let{components:n,...r}=e;return(0,a.yg)(f,(0,t.A)({},u,r,{components:n,mdxType:"MDXLayout"}),(0,a.yg)("h2",{id:"array_difference"},"array_difference"),(0,a.yg)("version",{since:"1.2.0"},(0,a.yg)("p",null,"array_difference")),(0,a.yg)("h3",{id:"description"},"description"),(0,a.yg)("h4",{id:"syntax"},"Syntax"),(0,a.yg)("p",null,(0,a.yg)("inlineCode",{parentName:"p"},"ARRAY<T> array_difference(ARRAY<T> arr)")),(0,a.yg)("p",null,"Calculates the difference between adjacent array elements.\nReturns an array where the first element will be 0, the second is the difference between a","[1]"," - a","[0]",".\nneed notice that NULL will be return NULL"),(0,a.yg)("h3",{id:"notice"},"notice"),(0,a.yg)("p",null,(0,a.yg)("inlineCode",{parentName:"p"},"Only supported in vectorized engine")),(0,a.yg)("h3",{id:"example"},"example"),(0,a.yg)("pre",null,(0,a.yg)("code",{parentName:"pre"},"mysql> set enable_vectorized_engine=true;\n\nmysql> select *,array_difference(k2) from array_type_table;\n+------+-----------------------------+---------------------------------+\n| k1 | k2 | array_difference(`k2`) |\n+------+-----------------------------+---------------------------------+\n| 0 | [] | [] |\n| 1 | [NULL] | [NULL] |\n| 2 | [1, 2, 3] | [0, 1, 1] |\n| 3 | [1, NULL, 3] | [0, NULL, NULL] |\n| 4 | [0, 1, 2, 3, NULL, 4, 6] | [0, 1, 1, 1, NULL, NULL, 2] |\n| 5 | [1, 2, 3, 4, 5, 4, 3, 2, 1] | [0, 1, 1, 1, 1, -1, -1, -1, -1] |\n| 6 | [6, 7, 8] | [0, 1, 1] |\n+------+-----------------------------+---------------------------------+\n")),(0,a.yg)("h3",{id:"keywords"},"keywords"),(0,a.yg)("p",null,"ARRAY, DIFFERENCE, ARRAY_DIFFERENCE"))}y.isMDXComponent=!0}}]);