# H2 type mapping

> For the complete documentation index, see [llms.txt](https://kotlin.github.io/dataframe/llms.txt).

The tables below list every H2 column type ([H2 Data Types](https://www.h2database.com/html/datatypes.html)) and the Kotlin type produced when the column is read into a DataFrame in `H2.Mode.Regular`. Aliases are canonicalized by H2 at `CREATE TABLE` time, so DataFrame only ever sees the canonical type; they are listed in the same row as the canonical type for reference.

API reference: [H2](https://kotlin.github.io/dataframe/api-docs/dataframe-jdbc/org.jetbrains.kotlinx.dataframe.io.db/-h2/index.html)

For non-`Regular` modes, H2 delegates to the emulated dialect — see the [Mode section](#h2-modes) below.

Column nullability is determined from the metadata provided by the JDBC driver. If the driver does not explicitly report a column as non-nullable, it is mapped to a nullable Kotlin type (`Int?` instead of `Int`).

## Character types

| Canonical | Aliases | DataFrame column type | Notes |
| --- | --- | --- | --- |
| `CHAR[(n)]` | `CHARACTER`, `NCHAR` | `String` | Fixed-length text. |
| `VARCHAR[(n)]` | `CHARACTER VARYING`, `LONGVARCHAR`, `VARCHAR2`, `NVARCHAR`, `NVARCHAR2`, `VARCHAR_CASESENSITIVE` | `String` | Variable-length text. |
| `VARCHAR_IGNORECASE[(n)]` | none | `String` | Case-insensitive comparison; stored as text. |
| `CLOB` | `CHARACTER LARGE OBJECT`, `TINYTEXT`, `TEXT`, `MEDIUMTEXT`, `LONGTEXT`, `NTEXT`, `NCLOB` | `java.sql.Clob` | Large text object. |

## Binary types

| Canonical | Aliases | DataFrame column type | Notes |
| --- | --- | --- | --- |
| `BINARY[(n)]` | `RAW` | `ByteArray` | Fixed-length binary. |
| `VARBINARY[(n)]` | `LONGVARBINARY`, `BINARY VARYING` | `ByteArray` | Variable-length binary. |
| `BLOB` | `BINARY LARGE OBJECT`, `TINYBLOB`, `MEDIUMBLOB`, `LONGBLOB`, `IMAGE` | `java.sql.Blob` | Large binary object. |

## Boolean

| Canonical | Aliases | DataFrame column type | Notes |
| --- | --- | --- | --- |
| `BOOLEAN` | `BOOL`, `BIT`, `LOGICAL` | `Boolean` | Single-bit boolean. |

## Numeric types

| Canonical | Aliases | DataFrame column type | Notes |
| --- | --- | --- | --- |
| `TINYINT` | none | `Int` | 1-byte signed integer. |
| `SMALLINT` | `INT2`, `YEAR` | `Int` | 2-byte signed integer. |
| `INTEGER` | `INT`, `INT4`, `MEDIUMINT`, `SIGNED` | `Int` | 4-byte signed integer. |
| `BIGINT` | `INT8` | `Long` | 8-byte signed integer. |
| `NUMERIC[(p[,s])]` | `DECIMAL[(p[,s])]`, `DEC[(p[,s])]`, `NUMBER[(p[,s])]` | `java.math.BigDecimal` | Fixed-point. |
| `REAL` | `FLOAT4` | `Float` | 4-byte float. |
| `DOUBLE PRECISION` | `DOUBLE`, `FLOAT`, `FLOAT8` | `Double` | 8-byte float. |
| `DECFLOAT[(p)]` | none | `java.math.BigDecimal` | Decimal floating-point (H2 2.0+). |

## Date and time types

| Canonical | Aliases | DataFrame column type | Notes |
| --- | --- | --- | --- |
| `DATE` | none | `java.util.Date` |   |
| `TIME[(p)] [WITHOUT TIME ZONE]` | none | `java.sql.Time` |   |
| `TIME[(p)] WITH TIME ZONE` | none | `java.time.OffsetTime` |   |
| `TIMESTAMP[(p)] [WITHOUT TIME ZONE]` | `DATETIME`, `SMALLDATETIME` | `kotlin.time.Instant` | Preprocessed from `java.sql.Timestamp`. |
| `TIMESTAMP[(p)] WITH TIME ZONE` | `DATETIMEOFFSET`, `TIMESTAMPTZ` | `java.time.OffsetDateTime` |   |
| `INTERVAL YEAR[(p)]`, `INTERVAL MONTH[(p)]`, ... | none | `Any` | Any of the 13 interval subtypes; the value is an `org.h2.api.Interval`. |

## Other types

| Canonical | Aliases | DataFrame column type | Notes |
| --- | --- | --- | --- |
| `UUID` | none | `kotlin.uuid.Uuid` | Preprocessed from `java.util.UUID`. Driver reports `Types.BINARY` + `java.util.UUID` class. |
| `JAVA_OBJECT` | `OTHER` | `Any` | Serialized Java object; read as opaque `Any`. |
| `ENUM` | none | `Any` | User-declared enum labels. The value is always a `String`, but the driver reports the column as `Types.OTHER`, so the column type stays `Any`. |
| `GEOMETRY` | none | `Any` | Read as an opaque `Any`; the class of the value depends on whether JTS is on the classpath, and is an `org.locationtech.jts.geom.Geometry` when it is. |
| `JSON` | none | `ByteArray` | The JSON text as raw bytes: the driver returns a `byte[]` for this column. See the note below. |
| `ARRAY` | none | `Array<*>` | Element type inferred; falls back to `Any` for heterogeneous arrays. |
| `ROW(...)` | none | `String` (unsupported) |   |

A `JSON` column arrives as raw bytes rather than as text, so reading one and using it as a `String` takes an explicit decode — `convert { jsonCol }.with { it.toString(Charsets.UTF_8) }`. The same applies to `ENUM`, `GEOMETRY` and `INTERVAL`, whose columns are typed `Any`: the value has to be cast or converted before it can be used as the type it really is.

## Unsupported types

* [ROW(...)](https://www.h2database.com/html/datatypes.html#row_type) composite / structured types; driver reports `Types.OTHER`; DataFrame column type is `Any`.

* [INTERVAL](https://www.h2database.com/html/datatypes.html#interval_type) subtypes (all 13); read as their text form to a `String` column.

* [Domain types](https://www.h2database.com/html/commands.html#create_domain) (H2 supports `CREATE DOMAIN`); transparent at the JDBC layer — the underlying primitive's mapping applies with a column of the corresponding type.

* [GEOMETRY](https://www.h2database.com/html/datatypes.html#geometry_type) in binary/WKB form; DataFrame reads only the WKT text form to a `String` column.

## H2 modes

`H2(mode = ...)` selects the dialect H2 emulates and delegates its type mapping to that dialect. The default mode is `Regular`.

| Mode | Delegates to |
| --- | --- |
| `Regular` | Default H2 mapping (this page) |
| `MySql` | [MySQL](readsqltypemapping-mysql.html) |
| `PostgreSql` | [PostgreSQL](readsqltypemapping-postgresql.html) |
| `MsSqlServer` | [MS SQL](readsqltypemapping-mssql.html) |
| `MariaDb` | [MariaDB](readsqltypemapping-mariadb.html) |

