Help Center/ AI DataLake/ Flink reference/ Built-in Functions/ Value Construction Functions
Updated on 2026-11-06 GMT+08:00

Value Construction Functions

Overview

Value construction functions are used to construct values of composite data types, including rows, arrays, and maps. AI DataLake supports the implicit and explicit row construction, array construction, and map construction capabilities in the SQL standard.

For more information, see Value Construction Functions.

Application Scenarios

  • Composite row construction: The ROW construction function is used to create row values that contain multiple columns.
  • Array construction: The ARRAY construction function is used to create array values, which are used in the IN clause and UNNEST operation.
  • Mapping construction: The MAP construction function is used to create key-value pair maps, which are used to configure parameters and store attributes.
  • Window definition: The row number interval construction function is used to assist window definition.

Notes and Constraints

  • Implicit row construction (using parentheses) requires at least two columns. The explicit ROW construction function can accept any number of columns.
  • The value types in the ARRAY and MAP construction functions must be consistent or compatible.
  • The parameters of the MAP construction function must appear in pairs. That is, the number of key-value pairs must be an even number.
  • The row interval construction function (N rows) is supported only by Table API and is not available in SQL.

Syntax Structure

Syntax

Return Type

Description

Example

implicit constructor with parenthesis

(value1 [, value2]*)

explicit ROW constructor with

ROW(value1 [, value2]*)

ROW

Creates a row from a list of values (value1, value2, ...).

The implicit row constructor requires at least two fields. The explicit row constructor can handle any number of fields. Both support any expression as a field.

-- Implicit row constructor (at least two fields)
SELECT (1, 'hello'); 
-- Explicit row constructor (can handle any number of fields)
SELECT ROW(1);
SELECT ROW(1, 'hello', TRUE);
-- Using expressions as fields
SELECT ROW(orderId, orderAmount) FROM orders;

ARRAY '[' value1 [, value2 ]* ']'

ARRAY

Creates an array from a list of values (value1, value2, ...).

-- Create an array from literals.
SELECT ARRAY [1, 2, 3]; 
-- Create an array from expressions.
SELECT ARRAY [orderId, orderAmount] FROM orders;
-- Create a nested array.
SELECT ARRAY [ARRAY [1, 2], ARRAY [3, 4]];

MAP '[' value1, value2 [, value3, value4 ]* ']'

MAP

Creates a map from a list of key-value pairs ((value1, value2), (value3, value4), ...).

-- Create a map from literals.
SELECT MAP ['a', 1, 'b', 2]; 
-- Create a map from expressions.
SELECT MAP ['orderId', orderId, 'amount', orderAmount] FROM orders;