blob: 30dc14a62527c1af51a1515498ff76863bae0152 [file] [log] [blame]
"use strict";(self.webpackChunkdoris_website=self.webpackChunkdoris_website||[]).push([[91029],{15680:(e,t,n)=>{n.d(t,{xA:()=>u,yg:()=>d});var r=n(296540);function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){l(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function c(e,t){if(null==e)return{};var n,r,l=function(e,t){if(null==e)return{};var n,r,l={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(l[n]=e[n]);return l}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n])}return l}var i=r.createContext({}),s=function(e){var t=r.useContext(i),n=t;return e&&(n="function"==typeof e?e(t):a(a({},t),e)),n},u=function(e){var t=s(e.components);return r.createElement(i.Provider,{value:t},e.children)},p="mdxType",g={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},y=r.forwardRef((function(e,t){var n=e.components,l=e.mdxType,o=e.originalType,i=e.parentName,u=c(e,["components","mdxType","originalType","parentName"]),p=s(n),y=l,d=p["".concat(i,".").concat(y)]||p[y]||g[y]||o;return n?r.createElement(d,a(a({ref:t},u),{},{components:n})):r.createElement(d,a({ref:t},u))}));function d(e,t){var n=arguments,l=t&&t.mdxType;if("string"==typeof e||l){var o=n.length,a=new Array(o);a[0]=y;var c={};for(var i in t)hasOwnProperty.call(t,i)&&(c[i]=t[i]);c.originalType=e,c[p]="string"==typeof e?e:l,a[1]=c;for(var s=2;s<o;s++)a[s]=n[s];return r.createElement.apply(null,a)}return r.createElement.apply(null,n)}y.displayName="MDXCreateElement"},184046:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>a,default:()=>g,frontMatter:()=>o,metadata:()=>c,toc:()=>s});var r=n(58168),l=(n(296540),n(15680));const o={title:"COLLECT_SET",language:"en"},a=void 0,c={unversionedId:"sql-manual/sql-functions/aggregate-functions/collect-set",id:"sql-manual/sql-functions/aggregate-functions/collect-set",title:"COLLECT_SET",description:"\x3c!--",source:"@site/docs/sql-manual/sql-functions/aggregate-functions/collect-set.md",sourceDirName:"sql-manual/sql-functions/aggregate-functions",slug:"/sql-manual/sql-functions/aggregate-functions/collect-set",permalink:"/docs/dev/sql-manual/sql-functions/aggregate-functions/collect-set",draft:!1,tags:[],version:"current",frontMatter:{title:"COLLECT_SET",language:"en"},sidebar:"docs",previous:{title:"BITMAP_AGG",permalink:"/docs/dev/sql-manual/sql-functions/aggregate-functions/bitmap-agg"},next:{title:"COLLECT_LIST",permalink:"/docs/dev/sql-manual/sql-functions/aggregate-functions/collect-list"}},i={},s=[{value:"COLLECT_SET",id:"collect_set",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},p="wrapper";function g(e){let{components:t,...n}=e;return(0,l.yg)(p,(0,r.A)({},u,n,{components:t,mdxType:"MDXLayout"}),(0,l.yg)("h2",{id:"collect_set"},"COLLECT_SET"),(0,l.yg)("version",{since:"1.2.0"},(0,l.yg)("p",null,"COLLECT_SET")),(0,l.yg)("h3",{id:"description"},"description"),(0,l.yg)("h4",{id:"syntax"},"Syntax"),(0,l.yg)("p",null,(0,l.yg)("inlineCode",{parentName:"p"},"ARRAY<T> collect_set(expr[,max_size])")),(0,l.yg)("p",null,"Creates an array containing distinct elements from ",(0,l.yg)("inlineCode",{parentName:"p"},"expr"),",with the optional ",(0,l.yg)("inlineCode",{parentName:"p"},"max_size")," parameter limits the size of the resulting array to ",(0,l.yg)("inlineCode",{parentName:"p"},"max_size")," elements. It has an alias ",(0,l.yg)("inlineCode",{parentName:"p"},"group_uniq_array"),"."),(0,l.yg)("h3",{id:"notice"},"notice"),(0,l.yg)("pre",null,(0,l.yg)("code",{parentName:"pre"},"Only supported in vectorized engine\n")),(0,l.yg)("h3",{id:"example"},"example"),(0,l.yg)("pre",null,(0,l.yg)("code",{parentName:"pre"},"mysql> set enable_vectorized_engine=true;\n\nmysql> select k1,k2,k3 from collect_set_test order by k1;\n+------+------------+-------+\n| k1 | k2 | k3 |\n+------+------------+-------+\n| 1 | 2023-01-01 | hello |\n| 2 | 2023-01-01 | NULL |\n| 2 | 2023-01-02 | hello |\n| 3 | NULL | world |\n| 3 | 2023-01-02 | hello |\n| 4 | 2023-01-02 | doris |\n| 4 | 2023-01-03 | sql |\n+------+------------+-------+\n\nmysql> select collect_set(k1),collect_set(k1,2) from collect_set_test;\n+-------------------------+--------------------------+\n| collect_set(`k1`) | collect_set(`k1`,2) |\n+-------------------------+--------------------------+\n| [4,3,2,1] | [1,2] |\n+----------------------------------------------------+\n\nmysql> select k1,collect_set(k2),collect_set(k3,1) from collect_set_test group by k1 order by k1;\n+------+-------------------------+--------------------------+\n| k1 | collect_set(`k2`) | collect_set(`k3`,1) |\n+------+-------------------------+--------------------------+\n| 1 | [2023-01-01] | [hello] |\n| 2 | [2023-01-01,2023-01-02] | [hello] |\n| 3 | [2023-01-02] | [world] |\n| 4 | [2023-01-02,2023-01-03] | [sql] |\n+------+-------------------------+--------------------------+\n\n")),(0,l.yg)("h3",{id:"keywords"},"keywords"),(0,l.yg)("p",null,"COLLECT_SET,GROUP_UNIQ_ARRAY,COLLECT_LIST,ARRAY"))}g.isMDXComponent=!0}}]);