Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Apache Paimon ArrayType

From Leeroopedia


Knowledge Sources
Domains Type System, Data Structures
Last Updated 2026-02-08 00:00 GMT

Overview

ArrayType represents a data type for arrays of elements with the same subtype in Apache Paimon's type system.

Description

ArrayType is a final class extending DataType that represents an array collection type containing elements of a single, uniform data type. Unlike the SQL standard where array cardinality can be specified, Paimon's ArrayType has a fixed maximum cardinality of Integer.MAX_VALUE. The type supports any valid DataType as its element type, providing flexibility for complex nested data structures.

The class provides functionality for serialization to JSON and SQL string formats, equality checking including field ID comparisons, and visitor pattern support for type system traversal. ArrayType is nullable by default but can be configured as non-nullable through its constructor. The type integrates seamlessly with Paimon's broader type system, supporting operations like copying with different nullability settings and collecting field IDs from nested structures.

ArrayType has been available since Paimon version 0.4.0 and is marked with the @Public annotation, indicating its stability as part of the public API. The implementation ensures immutability and type safety through precondition checks on the element type.

Usage

Use ArrayType when defining table schemas or data structures that require homogeneous collections of elements, such as lists of integers, arrays of strings, or nested arrays for complex hierarchical data. It is particularly useful for representing repeated fields in structured data formats like JSON or Parquet.

Code Reference

Source Location

Signature

@Public
public final class ArrayType extends DataType {

    public ArrayType(boolean isNullable, DataType elementType)

    public ArrayType(DataType elementType)

    public DataType getElementType()

    public DataType newElementType(DataType newElementType)

    @Override
    public int defaultSize()

    @Override
    public DataType copy(boolean isNullable)

    @Override
    public String asSQLString()

    @Override
    public <R> R accept(DataTypeVisitor<R> visitor)
}

Import

import org.apache.paimon.types.ArrayType;

I/O Contract

Inputs

Name Type Required Description
isNullable boolean No Whether the array type can contain null values (default: true)
elementType DataType Yes The data type of elements contained in the array

Outputs

Name Type Description
ArrayType instance ArrayType A configured array type for use in schemas and type operations
SQL string String SQL representation in format "ARRAY<element_type>" or "ARRAY<element_type> NOT NULL"
JSON JsonObject JSON serialization with type and element fields

Usage Examples

// Create an array of integers
DataType intArray = new ArrayType(DataTypes.INT());

// Create a non-nullable array of strings
DataType stringArray = new ArrayType(false, DataTypes.STRING());

// Create nested arrays (array of arrays)
DataType nestedArray = new ArrayType(new ArrayType(DataTypes.BIGINT()));

// Get element type
ArrayType array = new ArrayType(DataTypes.DOUBLE());
DataType elementType = array.getElementType(); // Returns DOUBLE type

// Convert to SQL string
String sql = intArray.asSQLString(); // Returns "ARRAY<INT>"

// Create new array with different element type
DataType newArray = array.newElementType(DataTypes.FLOAT());

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment