<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>OpenText Analytics Database 26.2.x – Complex types</title>
    <link>/en/sql-reference/data-types/complex-types/</link>
    <description>Recent content in Complex types on OpenText Analytics Database 26.2.x</description>
    <generator>Hugo -- gohugo.io</generator>
    
	  <atom:link href="/en/sql-reference/data-types/complex-types/index.xml" rel="self" type="application/rss+xml" />
    
    
      
        
      
    
    
    <item>
      <title>Sql-Reference: ARRAY</title>
      <link>/en/sql-reference/data-types/complex-types/array/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/data-types/complex-types/array/</guid>
      <description>
        
        
        &lt;p&gt;Represents array data. There are two types of arrays in OpenText™ Analytics Database:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Native array: a one-dimensional array of a primitive type. Native arrays are tracked in the &lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/types/#&#34;&gt;TYPES&lt;/a&gt; system table and used in native tables.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Non-native array: all other supported arrays, including arrays that contain other arrays (multi-dimensional arrays) or structs (&lt;a href=&#34;../../../../en/sql-reference/data-types/complex-types/row/#&#34;&gt;ROW&lt;/a&gt;s). Non-native arrays have some usage restrictions. Non-native arrays are tracked in the &lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/complex-types/#&#34;&gt;COMPLEX_TYPES&lt;/a&gt; system table.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Both types of arrays operate in the same way, but they have different OIDs.&lt;/p&gt;
&lt;p&gt;Arrays can be bounded, meaning they specify a maximum element count, or unbounded. Unbounded arrays have a maximum binary size, which can be set explicitly or defaulted. See &lt;a href=&#34;#bounds&#34;&gt;Limits on Element Count and Collection Size&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Selected parsers support using COPY to load arrays. See the documentation of individual parsers for more information.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;p&gt;In &lt;a href=&#34;#Syntax2&#34;&gt;column definitions&lt;/a&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
ARRAY[&lt;span class=&#34;code-variable&#34;&gt;data_type&lt;/span&gt;, &lt;span class=&#34;code-variable&#34;&gt;max_elements&lt;/span&gt;] |
ARRAY[&lt;span class=&#34;code-variable&#34;&gt;data_type&lt;/span&gt;](&lt;span class=&#34;code-variable&#34;&gt;max_size&lt;/span&gt;) |
ARRAY[&lt;span class=&#34;code-variable&#34;&gt;data_type&lt;/span&gt;]
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In &lt;a href=&#34;#Syntax&#34;&gt;literals&lt;/a&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;ARRAY[&lt;span class=&#34;code-variable&#34;&gt;value&lt;/span&gt;[, ...] ]
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;restrictions&#34;&gt;Restrictions&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Native arrays support only data of primitive types, for example, int, UUID, and so on.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Array dimensionality is enforced. A column cannot contain arrays of varying dimensions. For example, a column that contains a three-dimensional array can only contain other three-dimensional arrays; it cannot simultaneously include a one-dimensional array. However, the arrays in a column can vary in size, where one array can contain four elements while another contains ten.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Array bounds, if specified, are enforced for all operations that load or alter data. Unbounded arrays may have as many elements as will fit in the allotted binary size.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;An array has a maximum binary size. If this size is not set when the array is defined, a default value is used.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Arrays do not support LONG types (like LONG VARBINARY or LONG VARCHAR) or user-defined types (like Geometry).&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a name=&#34;Syntax2&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;syntax-for-column-definition&#34;&gt;Syntax for column definition&lt;/h2&gt;
&lt;p&gt;Arrays used in column definitions can be either bounded or unbounded. Bounded arrays must specify a maximum number of elements. Unbounded arrays can specify a maximum binary size (in bytes) for the array, or the value of &lt;a href=&#34;../../../../en/sql-reference/config-parameters/general-parameters/#DefaultArrayBinarySize&#34;&gt;DefaultArrayBinarySize&lt;/a&gt; is used. You can specify a bound or a binary size but not both. For more information about these values, see &lt;a href=&#34;#bounds&#34;&gt;Limits on Element Count and Collection Size&lt;/a&gt;.

&lt;table class=&#34;table table-bordered&#34; &gt;



&lt;tr&gt; 

&lt;th &gt;
Type&lt;/th&gt; 

&lt;th &gt;
Syntax&lt;/th&gt; 

&lt;th &gt;
Semantics&lt;/th&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
Bounded array&lt;/td&gt; 

&lt;td &gt;






&lt;p&gt;&lt;code&gt;ARRAY[&lt;/code&gt;&lt;em&gt;&lt;code&gt;data_type&lt;/code&gt;&lt;/em&gt;&lt;code&gt;, &lt;/code&gt;&lt;em&gt;&lt;code&gt;max_elements&lt;/code&gt;&lt;/em&gt;&lt;code&gt;]&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;ARRAY[VARCHAR(50),100]&lt;/code&gt;&lt;/p&gt;
&lt;/td&gt; 

&lt;td &gt;




&lt;p&gt;Can contain no more than &lt;em&gt;&lt;code&gt;max_elements&lt;/code&gt;&lt;/em&gt; elements. Attempting to add more is an error.&lt;/p&gt;
&lt;p&gt;Has a binary size of the size of the data type multiplied by the maximum number of elements (possibly rounded up).&lt;/p&gt;
&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
Unbounded array with maximum binary size&lt;/td&gt; 

&lt;td &gt;






&lt;p&gt;&lt;code&gt;ARRAY[&lt;/code&gt;&lt;em&gt;&lt;code&gt;data_type&lt;/code&gt;&lt;/em&gt;&lt;code&gt;](&lt;/code&gt;&lt;em&gt;&lt;code&gt;max_size&lt;/code&gt;&lt;/em&gt;&lt;code&gt;)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;ARRAY[VARCHAR(50)](32000)&lt;/code&gt;&lt;/p&gt;
&lt;/td&gt; 

&lt;td &gt;


Can contain as many elements as fit in &lt;em&gt;&lt;code&gt;max_size&lt;/code&gt;&lt;/em&gt;. Ignores the value of DefaultArrayBinarySize.&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
Unbounded array with default binary size&lt;/td&gt; 

&lt;td &gt;






&lt;p&gt;&lt;code&gt;ARRAY[&lt;/code&gt;&lt;em&gt;&lt;code&gt;data_type&lt;/code&gt;&lt;/em&gt;&lt;code&gt;]&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;ARRAY[VARCHAR(50)]&lt;/code&gt;&lt;/p&gt;
&lt;/td&gt; 

&lt;td &gt;






&lt;p&gt;Can contain as many elements as fit in the default binary size.&lt;/p&gt;
&lt;p&gt;Equivalent to:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;ARRAY[&lt;/code&gt;&lt;em&gt;&lt;code&gt;data_type&lt;/code&gt;&lt;/em&gt;&lt;code&gt;](DefaultArrayBinarySize)&lt;/code&gt;&lt;/p&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/p&gt;
&lt;p&gt;The following example defines a table for customers using an unbounded array:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE customers (id INT, name VARCHAR, email ARRAY[VARCHAR(50)]);
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The following example uses a bounded array for customer email addresses and an unbounded array for order history:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE customers (id INT, name VARCHAR, email ARRAY[VARCHAR(50),5], orders ARRAY[INT]);
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The following example uses an array that has ROW elements:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE orders(
  orderid INT,
  accountid INT,
  shipments ARRAY[
    ROW(
      shipid INT,
      address ROW(
        street VARCHAR,
        city VARCHAR,
        zip INT
        ),
      shipdate DATE
    )
  ]
 );
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To declare a multi-dimensional array, use nesting. For example, ARRAY[ARRAY[int]] specifies a two-dimensional array.&lt;/p&gt;
&lt;p&gt;&lt;a name=&#34;Syntax&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;syntax-for-direct-construction-literals&#34;&gt;Syntax for direct construction (literals)&lt;/h2&gt;
&lt;p&gt;Use the ARRAY keyword to construct an array value. The following example creates an array of integer values.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ARRAY[1,2,3];
 array
-------
 [1,2,3]
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You can nest an array inside another array, as in the following example.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ARRAY[ARRAY[1],ARRAY[2]];
   array
-----------
 [[1],[2]]
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If an array of arrays contains no null elements and no function calls, you can abbreviate the syntax:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ARRAY[[1,2],[3,4]];
     array
---------------
 [[1,2],[3,4]]
(1 row)

---not valid:
=&amp;gt; SELECT ARRAY[[1,2],null,[3,4]];

ERROR 4856:  Syntax error at or near &amp;#34;null&amp;#34; at character 20
LINE 1: SELECT ARRAY[[1,2],null,[3,4]];
                           ^
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Array literals can contain elements of all scalar types, ROW, and ARRAY. ROW elements must all have the same set of fields:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ARRAY[ROW(1,2),ROW(1,3)];
               array
-----------------------------------
 [{&amp;#34;f0&amp;#34;:1,&amp;#34;f1&amp;#34;:2},{&amp;#34;f0&amp;#34;:1,&amp;#34;f1&amp;#34;:3}]
(1 row)

=&amp;gt; SELECT ARRAY[ROW(1,2),ROW(1,3,&amp;#39;abc&amp;#39;)];
ERROR 3429:  For &amp;#39;ARRAY&amp;#39;, types ROW(int,int) and ROW(int,int,unknown) are inconsistent
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Because the elements are known at the time you directly construct an array, these arrays are implicitly bounded.&lt;/p&gt;
&lt;p&gt;You can use ARRAY literals in comparisons, as in the following example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT id.name, id.num, GPA FROM students
   WHERE major = ARRAY[ROW(&amp;#39;Science&amp;#39;,&amp;#39;Physics&amp;#39;)];
 name  | num | GPA
-------+-----+-----
 bob   | 121 | 3.3
 carol | 123 | 3.4
(2 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;output-format&#34;&gt;Output format&lt;/h2&gt;
&lt;p&gt;Queries of array columns return JSON format, with the values shown in comma-separated lists in brackets. The following example shows a query that includes array columns.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT cust_custkey,cust_custstaddress,cust_custcity,cust_custstate from cust;
cust_custkey |               cust_custstaddress                      |                cust_custcity                | cust_custstate
-------------+-------  ----------------------------------------------+---------------------------------------------+----------------
      342176 | [&amp;#34;668 SW New Lane&amp;#34;,&amp;#34;518 Main Ave&amp;#34;,&amp;#34;7040 Campfire Dr&amp;#34;] | [&amp;#34;Winchester&amp;#34;,&amp;#34;New Hyde Park&amp;#34;,&amp;#34;Massapequa&amp;#34;] | [&amp;#34;VA&amp;#34;,&amp;#34;NY&amp;#34;,&amp;#34;NY&amp;#34;]
      342799 | [&amp;#34;2400 Hearst Avenue&amp;#34;,&amp;#34;3 Cypress Street&amp;#34;]             | [&amp;#34;Berkeley&amp;#34;,&amp;#34;San Antonio&amp;#34;]                  | [&amp;#34;CA&amp;#34;,&amp;#34;TX&amp;#34;]
      342845 | [&amp;#34;336 Boylston Street&amp;#34;,&amp;#34;180 Clarkhill Rd&amp;#34;]            | [&amp;#34;Boston&amp;#34;,&amp;#34;Amherst&amp;#34;]                        | [&amp;#34;MA&amp;#34;,&amp;#34;MA&amp;#34;]
      342321 | [&amp;#34;95 Fawn Drive&amp;#34;]                                     | [&amp;#34;Allen Park&amp;#34;]                              | [&amp;#34;MI&amp;#34;]
      342989 | [&amp;#34;5 Thompson St&amp;#34;]                                     | [&amp;#34;Massillon&amp;#34;]                               | [&amp;#34;OH&amp;#34;]
(5 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Note that JSON format escapes some characters that would not be escaped in native VARCHARs. For example, if you insert &lt;code&gt;&amp;quot;c:\users\data&amp;quot;&lt;/code&gt; into an array, the JSON output for that value is &lt;code&gt;&amp;quot;c:\\users\\data&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;element-access&#34;&gt;Element access&lt;/h2&gt;
&lt;p&gt;Arrays are 0-indexed. The first element&#39;s ordinal position is 0, second is 1, and so on.&lt;/p&gt;
&lt;p&gt;You can access (dereference) elements from an array by index:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT (ARRAY[&amp;#39;a&amp;#39;,&amp;#39;b&amp;#39;,&amp;#39;c&amp;#39;,&amp;#39;d&amp;#39;,&amp;#39;e&amp;#39;])[1];
array
-------
b
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To specify a range, use the format &lt;em&gt;&lt;code&gt;start&lt;/code&gt;&lt;/em&gt;:&lt;em&gt;&lt;code&gt;end&lt;/code&gt;&lt;/em&gt;. The end of the range is non-inclusive.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT(ARRAY[&amp;#39;a&amp;#39;,&amp;#39;b&amp;#39;,&amp;#39;c&amp;#39;,&amp;#39;d&amp;#39;,&amp;#39;e&amp;#39;,&amp;#39;f&amp;#39;,&amp;#39;g&amp;#39;])[1:4];
array
---------
[&amp;#34;b&amp;#34;,&amp;#34;c&amp;#34;,&amp;#34;d&amp;#34;]
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To dereference an element from a multi-dimensional array, put each index in brackets:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT(ARRAY[ARRAY[1,2],ARRAY[3,4]])[0][0];
 array
-------
 1
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Out-of-bound index references return NULL.&lt;/p&gt;
&lt;p&gt;&lt;a name=&#34;bounds&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;limits-on-element-count-and-collection-size&#34;&gt;Limits on element count and collection size&lt;/h2&gt;
&lt;p&gt;When declaring a collection type for a table column, you can limit either the number of elements or the total binary size of the collection. During query processing, OpenText™ Analytics Database always reserves the maximum memory needed for the column, based on either the element count or the binary size. If this size is much larger than your data actually requires, setting one of these limits can improve query performance by reducing the amount of memory that must be reserved for the column.&lt;/p&gt;
&lt;p&gt;You can change the bounds of a collection, including changing between bounded and unbounded collections, by casting. See &lt;a href=&#34;#Casting&#34;&gt;Casting&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;A bounded collection specifies a maximum element count. A value in a bounded collection column may contain fewer elements, but it may not contain more. Any attempt to insert more elements into a bounded collection than the declared maximum is an error. A bounded collection has a binary size that is the product of the data-type size and the maximum number of elements, possibly rounded up.&lt;/p&gt;
&lt;p&gt;An unbounded collection specifies a binary size in bytes, explicitly or implicitly. It may contain as many elements as can fit in that binary size.&lt;/p&gt;

&lt;p&gt;If a nested array specifies bounds for all dimensions, the database sets a single bound that is the product of the bounds. In the following example, the inner and outer arrays each have a bound of 10, but only a total element count of 100 is enforced.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;ARRAY[ARRAY[INT,10],10]
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If a nested array specifies a bound for only the outer collection, it is treated as the total bound. The previous example is equivalent to the following:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;ARRAY[ARRAY[INT],100]
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You must either specify bounds for all nested collections or specify a bound only for the outer one. For any other distribution of bounds, the database treats the collection as unbounded.&lt;/p&gt;
&lt;p&gt;Instead of specifying a bound, you can specify a maximum binary size for an unbounded collection. The binary size acts as an absolute limit, regardless of how many elements the collection contains. Collections that do not specify a maximum binary size use the value of &lt;a href=&#34;../../../../en/sql-reference/config-parameters/general-parameters/#DefaultArrayBinarySize&#34;&gt;DefaultArrayBinarySize&lt;/a&gt;. This size is set at the time the collection is defined and is not affected by later changes to the value of DefaultArrayBinarySize.&lt;/p&gt;
&lt;p&gt;You cannot set a maximum binary size for a bounded collection, only an unbounded one.&lt;/p&gt;

&lt;p&gt;You can change the bounds or the binary size of an array column using &lt;a href=&#34;../../../../en/sql-reference/statements/alter-statements/alter-table/#&#34;&gt;ALTER TABLE&lt;/a&gt; as in the following example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; ALTER TABLE cust ALTER COLUMN orders SET DATA TYPE ARRAY[INTEGER](100);
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If the change reduces the size of the collection and would result in data loss, the change fails.&lt;/p&gt;
&lt;p&gt;&lt;a name=&#34;Comparis&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;comparisons&#34;&gt;Comparisons&lt;/h2&gt;
&lt;p&gt;All collections support equality (&lt;code&gt;=&lt;/code&gt;), inequality (&lt;code&gt;&amp;lt;&amp;gt;&lt;/code&gt;), and null-safe equality (&lt;code&gt;&amp;lt;=&amp;gt;&lt;/code&gt;). 1D collections also support comparison operators (&lt;code&gt;&amp;lt;&lt;/code&gt;, &lt;code&gt;&amp;lt;=&lt;/code&gt;, &lt;code&gt;&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;gt;=&lt;/code&gt;) between collections of the same type (arrays or sets). Comparisons follow these rules:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A null collection is ordered last.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Non-null collections are compared element by element, using the ordering rules of the element&#39;s data type. The relative order of the first pair of non-equal elements determines the order of the two collections.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If all elements in both collections are equal up to the length of the shorter collection, the shorter collection is ordered before the longer one.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If all elements in both collections are equal and the collections are of equal length, the collections are equal.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&#34;null-handling&#34;&gt;Null-handling&lt;/h2&gt;
&lt;p&gt;Null semantics for collections are consistent with normal columns in most regards. See &lt;a href=&#34;../../../../en/data-analysis/query-optimization/analytic-functions/null-sort-order/#&#34;&gt;NULL sort order&lt;/a&gt; for more information on null-handling.&lt;/p&gt;
&lt;p&gt;The null-safe equality operator (&amp;lt;=&amp;gt;) behaves differently from equality (=) when the collection is null rather than empty. Comparing a collection to NULL strictly returns null:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ARRAY[1,3] = NULL;
?column?
----------

(1 row)

=&amp;gt; SELECT ARRAY[1,3] &amp;lt;=&amp;gt; NULL;
 ?column?
----------
 f
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In the following example, the grants column in the table is null for employee 99:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT grants = NULL FROM employees WHERE id=99;
 ?column?
----------

(1 row)

=&amp;gt; SELECT grants &amp;lt;=&amp;gt; NULL FROM employees WHERE id=99;
 ?column?
----------
 t
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Empty collections are not null and behave as expected:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ARRAY[]::ARRAY[INT] = ARRAY[]::ARRAY[INT];
 ?column?
----------
 t
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Collections are compared element by element. If a comparison depends on a null element, the result is unknown (null), not false. For example, &lt;code&gt;ARRAY[1,2,null]=ARRAY[1,2,null]&lt;/code&gt; and &lt;code&gt;ARRAY[1,2,null]=ARRAY[1,2,3]&lt;/code&gt; both return null, but &lt;code&gt;ARRAY[1,2,null]=ARRAY[1,4,null]&lt;/code&gt; returns false because the second elements do not match.&lt;/p&gt;

&lt;p&gt;&lt;a name=&#34;Casting&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;casting&#34;&gt;Casting&lt;/h2&gt;
&lt;p&gt;Casting an array casts each element of the array. You can therefore cast between data types following the same rules as for casts of scalar values.&lt;/p&gt;
&lt;p&gt;You can cast both literal arrays and array columns explicitly:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ARRAY[&amp;#39;1&amp;#39;,&amp;#39;2&amp;#39;,&amp;#39;3&amp;#39;]::ARRAY[INT];
  array
---------
[1,2,3]
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You can change the bound of an array or set by casting. When casting to a bounded native array, inputs that are too long are truncated. When casting to a non-native array (an array containing complex data types including other arrays), if the new bounds are too small for the data the cast fails:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ARRAY[1,2,3]::ARRAY[VARCHAR,2];
   array
-----------
 [&amp;#34;1&amp;#34;,&amp;#34;2&amp;#34;]
(1 row)

=&amp;gt; SELECT ARRAY[ARRAY[1,2,3],ARRAY[4,5,6]]::ARRAY[ARRAY[VARCHAR,2],2];
ERROR 9227:  Output array isn&amp;#39;t big enough
DETAIL:  Type limit is 4 elements, but value has 6 elements
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If you cast to a bounded multi-dimensional array, you must specify the bounds at all levels:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ARRAY[ARRAY[1,2,3],ARRAY[4,5,6]]::ARRAY[ARRAY[VARCHAR,5],10];
             array
-------------------------------
 [[&amp;#34;1&amp;#34;,&amp;#34;2&amp;#34;,&amp;#34;3&amp;#34;],[&amp;#34;4&amp;#34;,&amp;#34;5&amp;#34;,&amp;#34;6&amp;#34;]]
(1 row)

=&amp;gt; SELECT ARRAY[ARRAY[1,2,3],ARRAY[4,5,6]]::ARRAY[ARRAY[VARCHAR,2]];
WARNING 9753:  Collection type bound will not be used
DETAIL:  A bound was provided for an inner dimension, but not for an outer dimension
             array
-------------------------------
 [[&amp;#34;1&amp;#34;,&amp;#34;2&amp;#34;,&amp;#34;3&amp;#34;],[&amp;#34;4&amp;#34;,&amp;#34;5&amp;#34;,&amp;#34;6&amp;#34;]]
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Assignment casts and implicit casts work the same way as for scalars:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE transactions (tid INT, prod_ids ARRAY[VARCHAR,100], quantities ARRAY[INT,100]);
CREATE TABLE

=&amp;gt; INSERT INTO transactions VALUES (12345, ARRAY[&amp;#39;p1265&amp;#39;, &amp;#39;p4515&amp;#39;], ARRAY[15,2]);
 OUTPUT
--------
      1
(1 row)

=&amp;gt; CREATE TABLE txreport (prod_ids ARRAY[VARCHAR(12),100], quants ARRAY[VARCHAR(32),100]);
CREATE TABLE

=&amp;gt; INSERT INTO txreport SELECT prod_ids, quantities FROM transactions;
 OUTPUT
--------
      1
(1 row)

=&amp;gt; SELECT * FROM txreport;
     prod_ids      |   quants
-------------------+------------
 [&amp;#34;p1265&amp;#34;,&amp;#34;p4515&amp;#34;] | [&amp;#34;15&amp;#34;,&amp;#34;2&amp;#34;]
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You can perform explicit casts, but not implicit casts, between the ARRAY and &lt;a href=&#34;../../../../en/sql-reference/data-types/complex-types/set/#&#34;&gt;SET&lt;/a&gt; types (native arrays only). If the collection is unbounded and the data type does not change, the binary size is preserved. For example, if you cast an ARRAY[INT] to a SET[INT], the set has the same binary size as the array.&lt;/p&gt;
&lt;p&gt;If you cast from one element type to another, the resulting collection uses the default binary size. If this would cause the data not to fit, the cast fails.&lt;/p&gt;
&lt;p&gt;You cannot cast from an array to an array with a different dimensionality, for example from a two-dimensional array to a one-dimensional array.&lt;/p&gt;
&lt;h2 id=&#34;functions-and-operators&#34;&gt;Functions and operators&lt;/h2&gt;
&lt;p&gt;See &lt;a href=&#34;../../../../en/sql-reference/functions/data-type-specific-functions/collection-functions/#&#34;&gt;Collection functions&lt;/a&gt; for a comprehensive list of functions that can be used to manipulate arrays and sets.&lt;/p&gt;
&lt;p&gt;Collections can be used in the following ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;As the grouping column in a &lt;a href=&#34;../../../../en/sql-reference/statements/select/group-by-clause/#&#34;&gt;GROUP BY clause&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For native arrays only, as the sort key in an &lt;a href=&#34;../../../../en/sql-reference/statements/select/order-by-clause/#&#34;&gt;ORDER BY clause&lt;/a&gt; in a query, in an OVER clause (see &lt;a href=&#34;../../../../en/data-analysis/sql-analytics/window-partitioning/#&#34;&gt;Window partitioning&lt;/a&gt;), or in a &lt;a href=&#34;../../../../en/sql-reference/statements/create-statements/create-projection/#&#34;&gt;CREATE PROJECTION&lt;/a&gt; statement.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;As the sort key in the PARTITION BY part of an OVER clause.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;As a JOIN key (see &lt;a href=&#34;../../../../en/sql-reference/statements/select/from-clause/joined-table/#&#34;&gt;Joined-table&lt;/a&gt;).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In &lt;a href=&#34;../../../../en/sql-reference/language-elements/expressions/case-expressions/#&#34;&gt;CASE expressions&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Collections cannot be used in the following ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;As part of an IN or NOT IN expression.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;As partition columns when creating tables.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;With ANALYZE_STATISTICS or TopK projections.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Non-native arrays only: ORDER BY, PARTITION BY, DEFAULT, SET USING, or constraints.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;


      </description>
    </item>
    
    <item>
      <title>Sql-Reference: MAP</title>
      <link>/en/sql-reference/data-types/complex-types/map/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/data-types/complex-types/map/</guid>
      <description>
        
        
        &lt;p&gt;Represents map data in external tables in the Parquet, ORC, and Avro formats only. A MAP must use only primitive types and may not contain other complex types. You can use the MAP type in a table definition to consume columns in the data, but you cannot query those columns.&lt;/p&gt;
&lt;p&gt;A superior alternative to MAP is &lt;a href=&#34;../../../../en/sql-reference/data-types/complex-types/array/#&#34;&gt;ARRAY&lt;/a&gt;[&lt;a href=&#34;../../../../en/sql-reference/data-types/complex-types/row/#&#34;&gt;ROW&lt;/a&gt;]. An array of rows can use all supported complex types and can be queried. This is the representation that &lt;a href=&#34;../../../../en/sql-reference/functions/management-functions/table-functions/infer-table-ddl/#&#34;&gt;INFER_TABLE_DDL&lt;/a&gt; suggests. For Avro data, the ROW must have fields named &lt;code&gt;key&lt;/code&gt; and &lt;code&gt;value&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Within a single table you must define all map columns using the same approach, MAP or ARRAY[ROW].&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;p&gt;In column definitions:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;MAP&amp;lt;&lt;span class=&#34;code-variable&#34;&gt;key&lt;/span&gt;,&lt;span class=&#34;code-variable&#34;&gt;value&lt;/span&gt;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;map-input-format-for-column-definition&#34;&gt;Map input format for column definition&lt;/h2&gt;
&lt;p&gt;In a column definition in an external table, a MAP consists of a key-value pair, specified as types. The table in the following example defines a map of product IDs to names.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE EXTERNAL TABLE store (storeID INT, inventory MAP&amp;lt;INT,VARCHAR(100)&amp;gt;)
    AS COPY FROM &amp;#39;...&amp;#39; PARQUET;
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: ROW</title>
      <link>/en/sql-reference/data-types/complex-types/row/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/data-types/complex-types/row/</guid>
      <description>
        
        
        &lt;p&gt;Represents structured data (structs). A ROW can contain fields of any primitive or complex type supported by OpenText™ Analytics Database.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;p&gt;In &lt;a href=&#34;#Syntax&#34;&gt;column definitions&lt;/a&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;ROW([&lt;span class=&#34;code-variable&#34;&gt;field&lt;/span&gt;] &lt;span class=&#34;code-variable&#34;&gt;type&lt;/span&gt;[, ...])
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If the field name is omitted, the database generates names starting with &amp;quot;f0&amp;quot;.&lt;/p&gt;
&lt;p&gt;In &lt;a href=&#34;#Syntax2&#34;&gt;literals&lt;/a&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;ROW(&lt;span class=&#34;code-variable&#34;&gt;value&lt;/span&gt; [AS &lt;span class=&#34;code-variable&#34;&gt;field&lt;/span&gt;] [, ...]) [AS &lt;span class=&#34;code-variable&#34;&gt;name&lt;/span&gt;(&lt;span class=&#34;code-variable&#34;&gt;field&lt;/span&gt;[, ...])]
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;a name=&#34;Syntax&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;syntax-for-column-definition&#34;&gt;Syntax for column definition&lt;/h2&gt;
&lt;p&gt;In a column definition, a ROW consists of one or more comma-separated pairs of field names and types. In the following example, the Parquet data file contains a struct for the address, which is read as a ROW in an external table:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE EXTERNAL TABLE customers (name VARCHAR,
    address ROW(street VARCHAR, city VARCHAR, zipcode INT))
    AS COPY FROM &amp;#39;...&amp;#39; PARQUET;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;ROWs can be nested; a field can have a type of ROW:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE employees(
    employeeID INT,
    personal ROW(
      name VARCHAR,
      address ROW(street VARCHAR, city VARCHAR, zipcode INT),
      taxID INT),
    department VARCHAR);
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;ROWs can contain arrays:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE customers(
  name VARCHAR,
  contact ROW(
    street VARCHAR,
    city VARCHAR,
    zipcode INT,
    email ARRAY[VARCHAR]
  ),
  accountid INT );
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;When loading data, the primitive types in the table definition must match those in the data. The ROW structure must also match; a ROW must contain all and only the fields in the struct in the data.&lt;/p&gt;
&lt;h3 id=&#34;restrictions-on-row-columns&#34;&gt;Restrictions on ROW columns&lt;/h3&gt;
&lt;p&gt;ROW columns have several restrictions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Maximum nesting depth is 100.&lt;/li&gt;
&lt;li&gt;OpenText™ Analytics Database tables support up to 9800 columns and fields. The ROW itself is not counted, only its fields.&lt;/li&gt;
&lt;li&gt;ROW columns cannot use any constraints (such as NOT NULL) or defaults.&lt;/li&gt;
&lt;li&gt;ROW fields cannot be auto_increment or setof.&lt;/li&gt;
&lt;li&gt;ROW definition must include at least one field.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Row&lt;/code&gt; is a reserved keyword within a ROW definition, but is permitted as the name of a table or column.&lt;/li&gt;
&lt;li&gt;Tables containing ROW columns cannot also contain IDENTITY, default, SET USING, or named sequence columns.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a name=&#34;Syntax2&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;syntax-for-direct-construction-literals&#34;&gt;Syntax for direct construction (literals)&lt;/h2&gt;
&lt;p&gt;In a literal, such as a value in a comparison operation, a ROW consists of one or more values. If you omit field names in the ROW expression, the database generates them automatically. If you do not coerce types, the database infers the types from the data values.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ROW(&amp;#39;Amy&amp;#39;,2,false);
                row
--------------------------------------------
 {&amp;#34;f0&amp;#34;:&amp;#34;Amy&amp;#34;,&amp;#34;f1&amp;#34;:2,&amp;#34;f2&amp;#34;:false}
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You can use an AS clause to name the ROW and its fields:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ROW(&amp;#39;Amy&amp;#39;,2,false) AS student(name, id, current);
               student
--------------------------------------------
 {&amp;#34;name&amp;#34;:&amp;#34;Amy&amp;#34;,&amp;#34;id&amp;#34;:2,&amp;#34;current&amp;#34;:false}
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You can also name individual fields using AS. This query produces the same output as the previous one:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ROW(&amp;#39;Amy&amp;#39; AS name, 2 AS id, false AS current) AS student;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You do not need to name all fields.&lt;/p&gt;
&lt;p&gt;In an array of ROW elements, if you use AS to name fields and the names differ among the elements, the database uses the right-most names for all elements:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ARRAY[ROW(&amp;#39;Amy&amp;#39; AS name, 2 AS id),ROW(&amp;#39;Fred&amp;#39; AS first_name, 4 AS id)];
                           array
------------------------------------------------------------
 [{&amp;#34;first_name&amp;#34;:&amp;#34;Amy&amp;#34;,&amp;#34;id&amp;#34;:2},{&amp;#34;first_name&amp;#34;:&amp;#34;Fred&amp;#34;,&amp;#34;id&amp;#34;:4}]
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You can coerce types explicitly:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ROW(&amp;#39;Amy&amp;#39;,2.5::int,false::varchar);
               row
------------------------------------------
 {&amp;#34;f0&amp;#34;:&amp;#34;Amy&amp;#34;,&amp;#34;f1&amp;#34;:3,&amp;#34;f2&amp;#34;:&amp;#34;f&amp;#34;}
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Escape single quotes in literal inputs using single quotes, as in the following example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ROW(&amp;#39;Howard&amp;#39;&amp;#39;s house&amp;#39;,2,false);
                      row
---------------------------------------------------
 {&amp;#34;f0&amp;#34;:&amp;#34;Howard&amp;#39;s house&amp;#34;,&amp;#34;f1&amp;#34;:2,&amp;#34;f2&amp;#34;:false}
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You can use fields of all scalar types, ROW, and ARRAY, as in the following example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT id.name, major, GPA FROM students
   WHERE id = ROW(&amp;#39;alice&amp;#39;,119, ARRAY[&amp;#39;alice@example.com&amp;#39;,&amp;#39;ap16@cs.example.edu&amp;#39;]);
 name  |               major                | GPA
-------+------------------------------------+-----
 alice | [{&amp;#34;school&amp;#34;:&amp;#34;Science&amp;#34;,&amp;#34;dept&amp;#34;:&amp;#34;CS&amp;#34;}] | 3.8
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;output-format&#34;&gt;Output format&lt;/h2&gt;
&lt;p&gt;ROW values are output in JSON format as in the following example.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE EXTERNAL TABLE customers (name VARCHAR,
    address ROW(street VARCHAR, city VARCHAR, zipcode INT))
    AS COPY FROM &amp;#39;...&amp;#39; PARQUET;

=&amp;gt; SELECT address FROM customers WHERE address.city =&amp;#39;Pasadena&amp;#39;;
                              address
--------------------------------------------------------------------
 {&amp;#34;street&amp;#34;:&amp;#34;100 Main St Apt 4B&amp;#34;,&amp;#34;city&amp;#34;:&amp;#34;Pasadena&amp;#34;,&amp;#34;zipcode&amp;#34;:91001}
 {&amp;#34;street&amp;#34;:&amp;#34;100 Main St Apt 4A&amp;#34;,&amp;#34;city&amp;#34;:&amp;#34;Pasadena&amp;#34;,&amp;#34;zipcode&amp;#34;:91001}
 {&amp;#34;street&amp;#34;:&amp;#34;23 Fifth Ave Apt 8C&amp;#34;,&amp;#34;city&amp;#34;:&amp;#34;Pasadena&amp;#34;,&amp;#34;zipcode&amp;#34;:91001}
 {&amp;#34;street&amp;#34;:&amp;#34;15 Raymond Dr&amp;#34;,&amp;#34;city&amp;#34;:&amp;#34;Pasadena&amp;#34;,&amp;#34;zipcode&amp;#34;:91003}
(4 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The following table specifies the mappings from OpenText™ Analytics Database data types to JSON data types.

&lt;table class=&#34;table table-bordered&#34; &gt;



&lt;tr&gt; 

&lt;th &gt;
OpenText™ Analytics Database Type&lt;/th&gt; 

&lt;th &gt;
JSON Type&lt;/th&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
Integer&lt;/td&gt; 

&lt;td &gt;
Integer&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
Float&lt;/td&gt; 

&lt;td &gt;
Numeric&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
Numeric&lt;/td&gt; 

&lt;td &gt;
Numeric&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
Boolean&lt;/td&gt; 

&lt;td &gt;
Boolean&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
All others&lt;/td&gt; 

&lt;td &gt;
String&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/p&gt;
&lt;p&gt;&lt;a name=&#34;Comparis&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;comparisons&#34;&gt;Comparisons&lt;/h2&gt;
&lt;p&gt;ROW supports equality (&lt;code&gt;=&lt;/code&gt;), inequality (&lt;code&gt;&amp;lt;&amp;gt;&lt;/code&gt;), and null-safe equality (&lt;code&gt;&amp;lt;=&amp;gt;&lt;/code&gt;) between inputs that have the same set of fields. ROWs that contain only primitive types, including nested ROWs of primitive types, also support comparison operators (&lt;code&gt;&amp;lt;&lt;/code&gt;, &lt;code&gt;&amp;lt;=&lt;/code&gt;, &lt;code&gt;&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;gt;=&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;Two ROWs are equal if and only if all fields are equal. The database compares fields in order until an inequality is found, or all fields have been compared. The evaluation of the first non-equal field determines which ROW is greater:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ROW(1, &amp;#39;joe&amp;#39;) &amp;gt; ROW(2, &amp;#39;bob&amp;#39;);
?column?
----------
f
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Comparisons between ROWs with different schemas fail:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ROW(1, &amp;#39;joe&amp;#39;) &amp;gt; ROW(2, &amp;#39;bob&amp;#39;, 123);
ERROR 5162:  Unequal number of entries in row expressions
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If the result of a comparison depends on a null field, the result is null:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt;  select row(1, null, 3) = row(1, 2, 3);
 ?column?
----------

(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;null-handling&#34;&gt;Null-handling&lt;/h2&gt;
&lt;p&gt;If a struct exists but a field value is null, the database assigns NULL as its value in the ROW. A struct where all fields are null is treated as a ROW with null fields. If the struct itself is null, the database reads the ROW as NULL.&lt;/p&gt;
&lt;h2 id=&#34;casting&#34;&gt;Casting&lt;/h2&gt;
&lt;p&gt;Casting a ROW casts each field. You can therefore cast between data types following the same rules as for casts of scalar values.&lt;/p&gt;
&lt;p&gt;The following example casts the &lt;code&gt;contact&lt;/code&gt; ROW in the customers table, changing the &lt;code&gt;zipcode&lt;/code&gt; field from INT to VARCHAR and adding a bound to the array:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT contact::ROW(VARCHAR,VARCHAR,VARCHAR,ARRAY[VARCHAR,20]) FROM customers;
                                                         contact

--------------------------------------------------------------------------------
-----------------------------------------
 {&amp;#34;street&amp;#34;:&amp;#34;911 San Marcos St&amp;#34;,&amp;#34;city&amp;#34;:&amp;#34;Austin&amp;#34;,&amp;#34;zipcode&amp;#34;:&amp;#34;73344&amp;#34;,&amp;#34;email&amp;#34;:[&amp;#34;missy@mit.edu&amp;#34;,&amp;#34;mcooper@cern.gov&amp;#34;]}
 {&amp;#34;street&amp;#34;:&amp;#34;100 Main St Apt 4B&amp;#34;,&amp;#34;city&amp;#34;:&amp;#34;Pasadena&amp;#34;,&amp;#34;zipcode&amp;#34;:&amp;#34;91001&amp;#34;,&amp;#34;email&amp;#34;:[&amp;#34;shelly@meemaw.name&amp;#34;,&amp;#34;cooper@caltech.edu&amp;#34;]}
 {&amp;#34;street&amp;#34;:&amp;#34;100 Main St Apt 4A&amp;#34;,&amp;#34;city&amp;#34;:&amp;#34;Pasadena&amp;#34;,&amp;#34;zipcode&amp;#34;:&amp;#34;91001&amp;#34;,&amp;#34;email&amp;#34;:[&amp;#34;hofstadter@caltech.edu&amp;#34;]}
 {&amp;#34;street&amp;#34;:&amp;#34;23 Fifth Ave Apt 8C&amp;#34;,&amp;#34;city&amp;#34;:&amp;#34;Pasadena&amp;#34;,&amp;#34;zipcode&amp;#34;:&amp;#34;91001&amp;#34;,&amp;#34;email&amp;#34;:[]}
 {&amp;#34;street&amp;#34;:null,&amp;#34;city&amp;#34;:&amp;#34;Pasadena&amp;#34;,&amp;#34;zipcode&amp;#34;:&amp;#34;91001&amp;#34;,&amp;#34;email&amp;#34;:[&amp;#34;raj@available.com&amp;#34;]}

(6 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You can specify new field names to change them in the output:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT contact::ROW(str VARCHAR, city VARCHAR, zip VARCHAR, email ARRAY[VARCHAR,
20]) FROM customers;
                                                     contact

--------------------------------------------------------------------------------
----------------------------------
 {&amp;#34;str&amp;#34;:&amp;#34;911 San Marcos St&amp;#34;,&amp;#34;city&amp;#34;:&amp;#34;Austin&amp;#34;,&amp;#34;zip&amp;#34;:&amp;#34;73344&amp;#34;,&amp;#34;email&amp;#34;:[&amp;#34;missy@mit.edu&amp;#34;,&amp;#34;mcooper@cern.gov&amp;#34;]}
 {&amp;#34;str&amp;#34;:&amp;#34;100 Main St Apt 4B&amp;#34;,&amp;#34;city&amp;#34;:&amp;#34;Pasadena&amp;#34;,&amp;#34;zip&amp;#34;:&amp;#34;91001&amp;#34;,&amp;#34;email&amp;#34;:[&amp;#34;shelly@meemaw.name&amp;#34;,&amp;#34;cooper@caltech.edu&amp;#34;]}
 {&amp;#34;str&amp;#34;:&amp;#34;100 Main St Apt 4A&amp;#34;,&amp;#34;city&amp;#34;:&amp;#34;Pasadena&amp;#34;,&amp;#34;zip&amp;#34;:&amp;#34;91001&amp;#34;,&amp;#34;email&amp;#34;:[&amp;#34;hofstadter@caltech.edu&amp;#34;]}
 {&amp;#34;str&amp;#34;:&amp;#34;23 Fifth Ave Apt 8C&amp;#34;,&amp;#34;city&amp;#34;:&amp;#34;Pasadena&amp;#34;,&amp;#34;zip&amp;#34;:&amp;#34;91001&amp;#34;,&amp;#34;email&amp;#34;:[]}
 {&amp;#34;str&amp;#34;:null,&amp;#34;city&amp;#34;:&amp;#34;Pasadena&amp;#34;,&amp;#34;zip&amp;#34;:&amp;#34;91001&amp;#34;,&amp;#34;email&amp;#34;:[&amp;#34;raj@available.com&amp;#34;]}
(6 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;supported-operators-and-predicates&#34;&gt;Supported operators and predicates&lt;/h2&gt;
&lt;p&gt;ROW values may be used in queries in the following ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;INNER and OUTER JOIN&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;#Comparis&#34;&gt;Comparisons&lt;/a&gt;, IN, BETWEEN (non-nullable filters only)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;IS NULL, IS NOT NULL&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;CASE&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;GROUP BY, ORDER BY&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;SELECT DISTINCT&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Arguments to user-defined scalar, transform, and analytic functions&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The following operators and predicates are not supported for ROW values:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Math operators&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Type coercion of whole rows (coercion of field values is supported)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;BITWISE, LIKE&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;MLA (ROLLUP, CUBE, GROUPING SETS)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Aggregate functions including MAX, MIN, and SUM&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Set operators including UNION, UNION ALL, MINUS, and INTERSECT&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;COUNT is not supported for ROWs returned from user-defined scalar functions, but is supported for ROW columns and literals.&lt;/p&gt;
&lt;p&gt;In comparison operations (including implicit comparisons like ORDER BY), a ROW literal is treated as the sequence of its field values. For example, the following two statements are equivalent:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;GROUP BY ROW(zipcode, city)
GROUP BY zipcode, city
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;using-rows-in-views-and-subqueries&#34;&gt;Using rows in views and subqueries&lt;/h2&gt;
&lt;p&gt;You can use ROW columns to construct views and in subqueries. Consider employee and customer tables with the following definitions:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE EXTERNAL TABLE customers(name VARCHAR,
        address ROW(street VARCHAR, city VARCHAR, zipcode INT), accountID INT)
    AS COPY FROM &amp;#39;...&amp;#39; PARQUET;

=&amp;gt; CREATE EXTERNAL TABLE employees(employeeID INT,
        personal ROW(name VARCHAR,
        address ROW(street VARCHAR, city VARCHAR, zipcode INT),
        taxID INT), department VARCHAR)
    AS COPY FROM &amp;#39;...&amp;#39; PARQUET;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The following example creates a view and queries it.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE VIEW neighbors (num_neighbors, area(city, zipcode))
AS SELECT count(*), ROW(address.city, address.zipcode)
FROM customers GROUP BY address.city, address.zipcode;
CREATE VIEW

=&amp;gt; SELECT employees.personal.name, neighbors.area FROM neighbors, employees
WHERE employees.personal.address.zipcode=neighbors.area.zipcode AND neighbors.nu
m_neighbors &amp;gt; 1;
        name        |                area
--------------------+-------------------------------------
 Sheldon Cooper     | {&amp;#34;city&amp;#34;:&amp;#34;Pasadena&amp;#34;,&amp;#34;zipcode&amp;#34;:91001}
 Leonard Hofstadter | {&amp;#34;city&amp;#34;:&amp;#34;Pasadena&amp;#34;,&amp;#34;zipcode&amp;#34;:91001}
(2 rows)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: SET</title>
      <link>/en/sql-reference/data-types/complex-types/set/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/data-types/complex-types/set/</guid>
      <description>
        
        
        &lt;p&gt;Represents a collection of unordered, unique elements. Sets may contain only primitive types. In sets, unlike in arrays, element position is not meaningful.&lt;/p&gt;
&lt;p&gt;Sets do not support LONG types (like LONG VARBINARY or LONG VARCHAR) or user-defined types (like Geometry).&lt;/p&gt;
&lt;p&gt;If you populate a set from an array, OpenText™ Analytics Database sorts the values and removes duplicate elements. If you do not care about element position and plan to run queries that check for the presence of specific elements (find, contains), using a set could improve query performance.&lt;/p&gt;
&lt;p&gt;Sets can be bounded, meaning they specify a maximum element count, or unbounded. Unbounded sets have a maximum binary size, which can be set explicitly or defaulted. See &lt;a href=&#34;#bounds&#34;&gt;Limits on Element Count and Collection Size&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;p&gt;In &lt;a href=&#34;#Syntax&#34;&gt;column definitions&lt;/a&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SET[&lt;span class=&#34;code-variable&#34;&gt;data_type&lt;/span&gt;, &lt;span class=&#34;code-variable&#34;&gt;max_elements&lt;/span&gt;] |
SET[&lt;span class=&#34;code-variable&#34;&gt;data_type&lt;/span&gt;](&lt;span class=&#34;code-variable&#34;&gt;max_size&lt;/span&gt;) |
SET[&lt;span class=&#34;code-variable&#34;&gt;data_type&lt;/span&gt;]
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In &lt;a href=&#34;#Syntax2&#34;&gt;literals&lt;/a&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SET[&lt;span class=&#34;code-variable&#34;&gt;value&lt;/span&gt;[, ...] ]
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;restrictions&#34;&gt;Restrictions&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Sets support only data of primitive (scalar) types.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Bounds, if specified, are enforced for all operations that load or alter data. Unbounded sets may have as many elements as will fit in the allotted binary size.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A set has a maximum binary size. If this size is not set when the set is defined, a default value is used.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name=&#34;Syntax&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;syntax-for-column-definition&#34;&gt;Syntax for column definition&lt;/h2&gt;
&lt;p&gt;Sets used in column definitions can be either bounded or unbounded. Bounded sets must specify a maximum number of elements. Unbounded sets can specify a maximum binary size for the set, or the value of &lt;a href=&#34;../../../../en/sql-reference/config-parameters/general-parameters/#DefaultArrayBinarySize&#34;&gt;DefaultArrayBinarySize&lt;/a&gt; is used. You can specify a bound or a binary size but not both. For more information about these values, see &lt;a href=&#34;#bounds&#34;&gt;Limits on Element Count and Collection Size&lt;/a&gt;.

&lt;table class=&#34;table table-bordered&#34; &gt;



&lt;tr&gt; 

&lt;th &gt;
Type&lt;/th&gt; 

&lt;th &gt;
Syntax&lt;/th&gt; 

&lt;th &gt;
Semantics&lt;/th&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
Bounded set&lt;/td&gt; 

&lt;td &gt;






&lt;p&gt;&lt;code&gt;SET[&lt;/code&gt;&lt;em&gt;&lt;code&gt;data_type&lt;/code&gt;&lt;/em&gt;&lt;code&gt;, &lt;/code&gt;&lt;em&gt;&lt;code&gt;max_elements&lt;/code&gt;&lt;/em&gt;&lt;code&gt;]&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;SET[VARCHAR(50),100]&lt;/code&gt;&lt;/p&gt;
&lt;/td&gt; 

&lt;td &gt;




&lt;p&gt;Can contain no more than &lt;em&gt;&lt;code&gt;max_elements&lt;/code&gt;&lt;/em&gt; elements. Attempting to add more is an error.&lt;/p&gt;
&lt;p&gt;Has a binary size of the size of the data type multiplied by the maximum number of elements (possibly rounded up).&lt;/p&gt;
&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
Unbounded set with maximum size&lt;/td&gt; 

&lt;td &gt;






&lt;p&gt;&lt;code&gt;SET[&lt;/code&gt;&lt;em&gt;&lt;code&gt;data_type&lt;/code&gt;&lt;/em&gt;&lt;code&gt;](&lt;/code&gt;&lt;em&gt;&lt;code&gt;max_size&lt;/code&gt;&lt;/em&gt;&lt;code&gt;)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;SET[VARCHAR(50)](32000)&lt;/code&gt;&lt;/p&gt;
&lt;/td&gt; 

&lt;td &gt;


Can contain as many elements as fit in &lt;em&gt;&lt;code&gt;max_size&lt;/code&gt;&lt;/em&gt;. Ignores the value of DefaultArrayBinarySize.&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
Unbounded set&lt;/td&gt; 

&lt;td &gt;






&lt;p&gt;&lt;code&gt;SET[&lt;/code&gt;&lt;em&gt;&lt;code&gt;data_type&lt;/code&gt;&lt;/em&gt;&lt;code&gt;]&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;SET[VARCHAR(50)]&lt;/code&gt;&lt;/p&gt;
&lt;/td&gt; 

&lt;td &gt;






&lt;p&gt;Can contain as many elements as fit in the default binary size.&lt;/p&gt;
&lt;p&gt;Equivalent to:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;SET[&lt;/code&gt;&lt;em&gt;&lt;code&gt;data_type&lt;/code&gt;&lt;/em&gt;&lt;code&gt;](DefaultArrayBinarySize)&lt;/code&gt;&lt;/p&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/p&gt;
&lt;p&gt;The following example defines a table with an unbounded set colum.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE users
(
user_id INTEGER,
display_name VARCHAR,
email_addrs SET[VARCHAR]
);
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;When you load array data into a column defined as a set, the array data is automatically converted to a set.&lt;/p&gt;
&lt;p&gt;&lt;a name=&#34;Syntax2&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;syntax-for-direct-construction-literals&#34;&gt;Syntax for direct construction (literals)&lt;/h2&gt;
&lt;p&gt;Use the SET keyword to construct a set value. Literal set values are contained in brackets. For example, to create a set of INT, you would do the following:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT SET[1,2,3];
  set
-------
 [1,2,3]
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You can explicitly convert an array to a set by casting, as in the following example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ARRAY[1, 5, 2, 6, 3, 0, 6, 4]::SET[INT];
     set
-----------------
[0,1,2,3,4,5,6]
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Notice that duplicate elements have been removed and the elements have been sorted.&lt;/p&gt;
&lt;p&gt;Because the elements are known at the time you directly construct a set, these sets are implicitly bounded.&lt;/p&gt;
&lt;h2 id=&#34;output-format&#34;&gt;Output format&lt;/h2&gt;
&lt;p&gt;Sets are shown in a JSON-like format, with comma-separated elements contained in brackets (like arrays). In the following example, the email_addrs column is a set.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT custkey,email_addrs FROM customers LIMIT 4;
 custkey |                           email_addrs
---------+------------------------------------------------------------------------
 342176  | [&amp;#34;joe.smith@example.com&amp;#34;]
 342799  | [&amp;#34;bob@example,com&amp;#34;,&amp;#34;robert.jones@example.com&amp;#34;]
 342845  | [&amp;#34;br92@cs.example.edu&amp;#34;]
 342321  | [&amp;#34;789123@example-isp.com&amp;#34;,&amp;#34;sjohnson@eng.example.com&amp;#34;,&amp;#34;sara@johnson.example.name&amp;#34;]
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;a name=&#34;bounds&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;limits-on-element-count-and-collection-size&#34;&gt;Limits on element count and collection size&lt;/h2&gt;
&lt;p&gt;When declaring a collection type for a table column, you can limit either the number of elements or the total binary size of the collection. During query processing, OpenText™ Analytics Database always reserves the maximum memory needed for the column, based on either the element count or the binary size. If this size is much larger than your data actually requires, setting one of these limits can improve query performance by reducing the amount of memory that must be reserved for the column.&lt;/p&gt;
&lt;p&gt;You can change the bounds of a collection, including changing between bounded and unbounded collections, by casting. See &lt;a href=&#34;#Casting&#34;&gt;Casting&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;A bounded collection specifies a maximum element count. A value in a bounded collection column may contain fewer elements, but it may not contain more. Any attempt to insert more elements into a bounded collection than the declared maximum is an error. A bounded collection has a binary size that is the product of the data-type size and the maximum number of elements, possibly rounded up.&lt;/p&gt;
&lt;p&gt;An unbounded collection specifies a binary size in bytes, explicitly or implicitly. It may contain as many elements as can fit in that binary size.&lt;/p&gt;

&lt;p&gt;Instead of specifying a bound, you can specify a maximum binary size for an unbounded collection. The binary size acts as an absolute limit, regardless of how many elements the collection contains. Collections that do not specify a maximum binary size use the value of &lt;a href=&#34;../../../../en/sql-reference/config-parameters/general-parameters/#DefaultArrayBinarySize&#34;&gt;DefaultArrayBinarySize&lt;/a&gt;. This size is set at the time the collection is defined and is not affected by later changes to the value of DefaultArrayBinarySize.&lt;/p&gt;
&lt;p&gt;You cannot set a maximum binary size for a bounded collection, only an unbounded one.&lt;/p&gt;

&lt;p&gt;&lt;a name=&#34;Comparis&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;comparisons&#34;&gt;Comparisons&lt;/h2&gt;
&lt;p&gt;All collections support equality (&lt;code&gt;=&lt;/code&gt;), inequality (&lt;code&gt;&amp;lt;&amp;gt;&lt;/code&gt;), and null-safe equality (&lt;code&gt;&amp;lt;=&amp;gt;&lt;/code&gt;). 1D collections also support comparison operators (&lt;code&gt;&amp;lt;&lt;/code&gt;, &lt;code&gt;&amp;lt;=&lt;/code&gt;, &lt;code&gt;&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;gt;=&lt;/code&gt;) between collections of the same type (arrays or sets). Comparisons follow these rules:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A null collection is ordered last.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Non-null collections are compared element by element, using the ordering rules of the element&#39;s data type. The relative order of the first pair of non-equal elements determines the order of the two collections.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If all elements in both collections are equal up to the length of the shorter collection, the shorter collection is ordered before the longer one.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If all elements in both collections are equal and the collections are of equal length, the collections are equal.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&#34;null-handling&#34;&gt;Null handling&lt;/h2&gt;
&lt;p&gt;Null semantics for collections are consistent with normal columns in most regards. See &lt;a href=&#34;../../../../en/data-analysis/query-optimization/analytic-functions/null-sort-order/#&#34;&gt;NULL sort order&lt;/a&gt; for more information on null-handling.&lt;/p&gt;
&lt;p&gt;The null-safe equality operator (&amp;lt;=&amp;gt;) behaves differently from equality (=) when the collection is null rather than empty. Comparing a collection to NULL strictly returns null:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ARRAY[1,3] = NULL;
?column?
----------

(1 row)

=&amp;gt; SELECT ARRAY[1,3] &amp;lt;=&amp;gt; NULL;
 ?column?
----------
 f
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In the following example, the grants column in the table is null for employee 99:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT grants = NULL FROM employees WHERE id=99;
 ?column?
----------

(1 row)

=&amp;gt; SELECT grants &amp;lt;=&amp;gt; NULL FROM employees WHERE id=99;
 ?column?
----------
 t
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Empty collections are not null and behave as expected:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ARRAY[]::ARRAY[INT] = ARRAY[]::ARRAY[INT];
 ?column?
----------
 t
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Collections are compared element by element. If a comparison depends on a null element, the result is unknown (null), not false. For example, &lt;code&gt;ARRAY[1,2,null]=ARRAY[1,2,null]&lt;/code&gt; and &lt;code&gt;ARRAY[1,2,null]=ARRAY[1,2,3]&lt;/code&gt; both return null, but &lt;code&gt;ARRAY[1,2,null]=ARRAY[1,4,null]&lt;/code&gt; returns false because the second elements do not match.&lt;/p&gt;

&lt;p&gt;&lt;a name=&#34;Casting&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;casting&#34;&gt;Casting&lt;/h2&gt;
&lt;p&gt;Casting a set casts each element of the set. You can therefore cast between data types following the same rules as for casts of scalar values.&lt;/p&gt;
&lt;p&gt;You can cast both literal sets and set columns explicitly:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT SET[&amp;#39;1&amp;#39;,&amp;#39;2&amp;#39;,&amp;#39;3&amp;#39;]::SET[INT];
   set
---------
[1,2,3]
(1 row)

=&amp;gt; CREATE TABLE transactions (tid INT, prod_ids SET[VARCHAR], quantities SET[VARCHAR(32)]);

=&amp;gt; INSERT INTO transactions VALUES (12345, SET[&amp;#39;p1265&amp;#39;, &amp;#39;p4515&amp;#39;], SET[&amp;#39;15&amp;#39;,&amp;#39;2&amp;#39;]);

=&amp;gt; SELECT quantities :: SET[INT] FROM transactions;
 quantities
------------
   [15,2]
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Assignment casts and implicit casts work the same way as for scalars.&lt;/p&gt;
&lt;p&gt;You can perform explicit casts, but not implicit casts, between &lt;a href=&#34;../../../../en/sql-reference/data-types/complex-types/array/#&#34;&gt;ARRAY&lt;/a&gt; and SET types. If the collection is unbounded and the data type does not change, the binary size is preserved. For example, if you cast an ARRAY[INT] to a SET[INT], the set has the same binary size as the array.&lt;/p&gt;
&lt;p&gt;When casting an array to a set, the database first casts each element and then sorts the set and removes duplicates. If two source values are cast to the same target value, one of them will be removed. For example, if you cast an array of FLOAT to a set of INT, two values in the array might be rounded to the same integer and then be treated as duplicates. This also happens if the array contains more than one value that is cast to NULL.&lt;/p&gt;
&lt;p&gt;If you cast from one element type to another, the resulting collection uses the default binary size. If this would cause the data not to fit, the cast fails.&lt;/p&gt;
&lt;h2 id=&#34;functions-and-operators&#34;&gt;Functions and operators&lt;/h2&gt;
&lt;p&gt;See &lt;a href=&#34;../../../../en/sql-reference/functions/data-type-specific-functions/collection-functions/#&#34;&gt;Collection functions&lt;/a&gt; for a comprehensive list of functions that can be used to manipulate arrays and sets.&lt;/p&gt;
&lt;p&gt;Collections can be used in the following ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;As the grouping column in a &lt;a href=&#34;../../../../en/sql-reference/statements/select/group-by-clause/#&#34;&gt;GROUP BY clause&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For native arrays only, as the sort key in an &lt;a href=&#34;../../../../en/sql-reference/statements/select/order-by-clause/#&#34;&gt;ORDER BY clause&lt;/a&gt; in a query, in an OVER clause (see &lt;a href=&#34;../../../../en/data-analysis/sql-analytics/window-partitioning/#&#34;&gt;Window partitioning&lt;/a&gt;), or in a &lt;a href=&#34;../../../../en/sql-reference/statements/create-statements/create-projection/#&#34;&gt;CREATE PROJECTION&lt;/a&gt; statement.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;As the sort key in the PARTITION BY part of an OVER clause.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;As a JOIN key (see &lt;a href=&#34;../../../../en/sql-reference/statements/select/from-clause/joined-table/#&#34;&gt;Joined-table&lt;/a&gt;).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In &lt;a href=&#34;../../../../en/sql-reference/language-elements/expressions/case-expressions/#&#34;&gt;CASE expressions&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Collections cannot be used in the following ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;As part of an IN or NOT IN expression.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;As partition columns when creating tables.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;With ANALYZE_STATISTICS or TopK projections.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Non-native arrays only: ORDER BY, PARTITION BY, DEFAULT, SET USING, or constraints.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;


      </description>
    </item>
    
  </channel>
</rss>
