Data Types

This page gives an overview of the data types supported by Polypheny.

Scalar Types

Type Description
BIGINT 8 bytes signed (two’s complement). Ranges from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
BOOLEAN 1-bit. Takes the value true and false.
DATE Represents a date. Format: yyyy-mm-dd
DECIMAL A decimal number is a number that can have a decimal point in it. This type has two arguments: precision (max. 64) and scale (max. 64). Precision is the total number of digits, scale is the number of digits to the right of the decimal point. The scale can not exceed the precision. If no arguments are provided, the default is 64,32.
DOUBLE 8 bytes IEEE 754. Covers a range from 4.94065645841246544e-324d to 1.79769313486231570e+308d (positive or negative).
INTEGER 4 bytes, signed (two’s complement). Covers a range from -2,147,483,648 to 2,147,483,647.
REAL 4 bytes, IEEE 754. Covers a range from 1.40129846432481707e-45 to 3.40282346638528860e+38 (positive or negative).
SMALLINT 2 bytes, signed (two’s complement). Covers a range from -32,768 to 32,767.
TEXT UTF-8 String with a size of up to 1GB.
TIME Represents a time of day without time zone. Optionally, precision can have a value between 0 and 3 specifying the number of fractional seconds. Format: hh:mm:ss.f
TIMESTAMP Represents a combination of DATE and TIME values. Optionally, precision can have a value between 0 and 3 specifying the number of fractional seconds. Format: yyyy-mm-dd hh:mm:ss.f
TINYINT 1 byte, signed (two’s complement). Covers a range from -128 to 127.
VARCHAR UTF-8 String with variable length. The maximum length is specified as parameter.

Array Types

An array is an ordered, contiguous collection that may contain duplicates. Polypheny supports arrays of all scalar types.

In Polypheny, arrays can have an arbitrary dimension and cardinality. Both are specified as arguments. Specifying -1 disables validation.

The dimension specifies how deep arrays can be nested. A dimension of one therefore means that nested arrays are not allowed while a dimension of two allows nested arrays but no nested arrays within nested arrays.

The cardinality specifies the number of elements (values and nested arrays) in every (nested) array.

Vector Types

A vector is a special form of an array. What is different to arrays, is that dimension is fixed to 1 and cardinality can only take values greater than 0. This forbids -1 to disable validation. Furthermore vectors cannot hold NULL elements. Since vectors do only have one parameter we speak of dimensions instead of cardinality in this context, this is not the dimension of an array described above.

Declaring a vector can be done with <base type> VECTOR(n). Only REAL, FLOAT and BOOLEAN are allowed as type. REAL and FLOAT result in a float vector, BOOLEAN in a bit vector. Any other base type is accepted by the parser but results in an ordinary array and not in a vector.

Example Description
REAL VECTOR(384) float vector, 384 dimensions
BOOLEAN VECTOR(256) bit vector, 256 dimensions

Values can be inserted as ordinary arrays.

CREATE TABLE listing (
    id          INTEGER NOT NULL,
    embedding   REAL VECTOR(3),
    PRIMARY KEY(id)
);

INSERT INTO listing VALUES (1, ARRAY[1.0, 2.0, 3.0]);

Multimedia and File Types

Polypheny natively supports storing files. In addition to the generic FILE data type there are also additional types for multimedia content. Multimedia files are not checked by their file extension, but by their content type. See SimpleMagic.ContentType for more information.

Type Description
AUDIO Accepted content types: AIFF, AUDIO/MPEG, MIDI, REAL/AUDIO, WAV
FILE Accepts files of any type.
IMAGE Accepted content types: APPLE_QUICKTIME_IMAGE, BMP, GIF, JPEG, JPEG 2000, PBM, PGM, PNG, PPM, SVG, TIFF
VIDEO Accepted content types: APPLE_QUICKTIME_MOVIE, AVI, MNG, MP4A, MP4V, VIDEO/MPEG
© Polypheny GmbH. All Rights Reserved.