You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by sk...@apache.org on 2019/06/08 22:17:47 UTC

svn commit: r1860865 [4/4] - in /phoenix/site: publish/array_type.html publish/language/datatypes.html publish/language/functions.html publish/language/index.html source/src/site/markdown/array_type.md

Modified: phoenix/site/source/src/site/markdown/array_type.md
URL: http://svn.apache.org/viewvc/phoenix/site/source/src/site/markdown/array_type.md?rev=1860865&r1=1860864&r2=1860865&view=diff
==============================================================================
--- phoenix/site/source/src/site/markdown/array_type.md (original)
+++ phoenix/site/source/src/site/markdown/array_type.md Sat Jun  8 22:17:46 2019
@@ -3,16 +3,14 @@
 The Apache Phoenix 3.0/4.0 release introduces support for the [JDBC ARRAY type](http://docs.oracle.com/javase/tutorial/jdbc/basics/array.html). Any primitive type may be used in an ARRAY. Here is an example of declaring an array type when creating a table:
 
     CREATE TABLE regions (
-        region_name VARCHAR PRIMARY KEY,
-        zips VARCHAR ARRAY[10],
-        CONSTRAINT pk PRIMARY KEY (region_name));
+        region_name VARCHAR NOT NULL PRIMARY KEY,
+        zips VARCHAR ARRAY[10]);
 
 or alternately:
 
     CREATE TABLE regions (
-        region_name VARCHAR PRIMARY KEY,
-        zips VARCHAR[],
-        CONSTRAINT pk PRIMARY KEY (region_name));
+        region_name VARCHAR NOT NULL PRIMARY KEY,
+        zips VARCHAR[]);
 
 Insertion into the array may be done entirely through a SQL statement:
 
@@ -34,11 +32,11 @@ The entire array may be selected:
 
 or an individual element in the array may be accessed via a subscript notation. The subscript is one-based, so the following would select the first element:
 
-    SELECT zip[1] FROM regions WHERE region_name = 'SF Bay Area';
+    SELECT zips[1] FROM regions WHERE region_name = 'SF Bay Area';
 
 Use of the array subscript notation is supported in other expressions as well, for example in a WHERE clause:
 
-    SELECT region_name FROM regions WHERE zip[1] = '94030' OR zip[2] = '94030' OR zip[3] = '94030';
+    SELECT region_name FROM regions WHERE zips[1] = '94030' OR zips[2] = '94030' OR zips[3] = '94030';
 
 The length of the array grows dynamically as needed with the current length and is accessible through the ARRAY_LENGTH build it function:
 
@@ -48,16 +46,16 @@ Attempts to access an array element beyo
 
 For searching in an array, built-in functions like ANY and ALL are provided.  For example,
 
-    SELECT region_name FROM regions WHERE '94030' = ANY(zip);
-    SELECT region_name FROM regions WHERE '94030' = ALL(zip);
+    SELECT region_name FROM regions WHERE '94030' = ANY(zips);
+    SELECT region_name FROM regions WHERE '94030' = ALL(zips);
 
 The built-in function ANY checks if any of the element in the array satisfies the condition and it is equivalent to OR condition:
 
-    SELECT region_name FROM regions WHERE zip[1] = '94030' OR zip[2] = '94030' OR zip[3] = '94030';
+    SELECT region_name FROM regions WHERE zips[1] = '94030' OR zips[2] = '94030' OR zips[3] = '94030';
 
 The built-in function ALL checks if all the elements in the array satisfies the condition and it is equivalent to AND condition:
 
-    SELECT region_name FROM regions WHERE zip[1] = '94030' AND zip[2] = '94030' AND zip[3] = '94030';
+    SELECT region_name FROM regions WHERE zips[1] = '94030' AND zips[2] = '94030' AND zips[3] = '94030';