Skip to content

npy ​

Description ​

One homogeneous NumPy array. Its first dimension supplies single-column rows; remaining dimensions become rectangular Array values. Mixed incompatible scalar types and ragged arrays are rejected.

Input and output. Select it with FORMAT npy. Names ignore ASCII case; use the snake_case name shown here.

Exactly one selected or target column is required. The first array dimension is the row count and later dimensions become nested Array values. Shapes must be rectangular and leaf types homogeneous.

Input accepts NPY 1.0, 2.0 and 3.0 in C order; output writes NPY 2.0 with little-endian numeric data. Output NULLs, ragged arrays and a SELECT with no rows are unsupported. A zero-row input with a valid header is accepted.

text
SELECT expressions FORMAT npy;
INSERT INTO table [(columns)] [SETTINGS ...] FORMAT npy
<data>

Example usage ​

Use the native client's --query mode to preserve binary output bytes. The server must be running, the executable available as ./coordinator, and database data selected.

sh
./coordinator client --database data --query "SELECT CAST(7 AS Int64) AS id FORMAT npy" > sample.npy
./coordinator client --database data --query "CREATE TABLE format_import(id Int64)" > /dev/null
./coordinator client --database data --query "INSERT INTO format_import FORMAT npy" < sample.npy > /dev/null
./coordinator client --database data --query "SELECT id FROM format_import FORMAT csv"
text
7

Create format_import in a fresh database before running this example.

Format settings ​

Use a statement SETTINGS clause; these options are not persisted by SET.

Setting Type Default Meaning
snappy_mode String basic Read Snappy client files as basic (Hadoop blocks) or framed (standard streaming format).

Type mappings ​

Input dtype Native leaf Output dtype
i1, i2, i4, i8 Signed integers of 8, 16, 32, or 64 bits. i8 for scalar results; declared width for Array members.
u1, u2, u4, u8 Unsigned integers of 8, 16, 32, or 64 bits; Bool accepts 0/1. u8 for scalar integers; declared width for Array members; u1 for Bool.
b1 UInt8 retains the stored byte; Bool reads zero as false and any nonzero byte as true. u8 for scalar integers; declared width for Array members; u1 for Bool.
f2, f4 Float32; binary16 expands exactly to binary32. f4.
f8 Float64. f8.
S<n> String/TEXT, BLOB, or FixedString. S<n> with zero padding; text uses the longest encoded byte length and FixedString retains its width.
U<n> UTF-32 code points decoded to UTF-8 text. S<n> containing UTF-8 bytes.