- DocumentDB SQL - Home
- DocumentDB SQL - Overview
- DocumentDB SQL - Select Clause
- DocumentDB SQL - From Clause
- DocumentDB SQL - Where Clause
- DocumentDB SQL - Operators
- DocumentDB - Between Keyword
- DocumentDB SQL - In Keyword
- DocumentDB SQL - Value Keyword
- DocumentDB SQL - Order By Clause
- DocumentDB SQL - Iteration
- DocumentDB SQL - Joins
- DocumentDB SQL - Aliasing
- DocumentDB SQL - Array Creation
- DocumentDB - Scalar Expressions
- DocumentDB SQL - Parameterized
- DocumentDB SQL - Built-in Function
- Linq to SQL Translation
- JavaScript Integration
- User-Defined Functions
- Composite SQL Queries
DocumentDB SQL - Array Function
The array functions perform an operation on an array input value and return in the form of numeric, Boolean or array value. Following are the built-in array functions.
| S.No. | Function & Description |
|---|---|
| 1 |
ARRAY_LENGTH (arr_expr) Returns the number of elements of the specified array expression. |
| 2 |
ARRAY_CONCAT (arr_expr, arr_expr [, arr_expr]) Returns an array that is the result of concatenating two or more array values. |
| 3 |
ARRAY_CONTAINS (arr_expr, expr) Returns a Boolean indicating whether the array contains the specified value. |
| 4 |
ARRAY_SLICE (arr_expr, num_expr [, num_expr]) Returns part of an array expression. |
Lets take a look at another example where some built-in array functions are used.
Following is the query with different array functions.
SELECT ARRAY_CONCAT(["A", "B"], ["1", "2"], ["#"]) AS ArrConcat, ARRAY_CONTAINS(["1A", "1B", "1C"], "1B") AS ArrContains, ARRAY_LENGTH(["1A", "1B", "1C"]) AS ArrLength, ARRAY_SLICE(["1A", "1B", "1C", "1D"], 1, 2) AS ArrSlice
When the above query is executed, it produces the following output.
[
{
"ArrConcat": [
"A",
"B",
"1",
"2",
"#"
],
"ArrContains": true,
"ArrLength": 3,
"ArrSlice": [
"1B",
"1C"
]
}
]