<commit_before>.. _data-types:

==========
Data types
==========

.. rubric:: Table of contents

.. contents::
   :local:

Type mapping
============

JDBC maps SQL types to `Plain Old Java Objects`_ (POJOs).

While this mapping is straightforward for most CrateDB types, for some it is
not.

The following table shows how the CrateDB types are mapped to `JDBC types`_ and
what method can be used to fetch them from a `ResultSet`_ instance:

+---------------+-----------------+------------------+
| CrateDB Type  | JDBC Type       | ResultSet Method |
+===============+=================+==================+
| `boolean`__   | `BOOLEAN`__     | ``getBoolean``   |
+---------------+-----------------+------------------+
| `byte`__      | `TINYINT`__     | ``getByte``      |
+---------------+-----------------+------------------+
| `short`__     | `SMALLINT`__    | ``getShort``     |
+---------------+-----------------+------------------+
| `integer`__   | `INTEGER`__     | ``getInteger``   |
+---------------+-----------------+------------------+
| `long`__      | `BIGINT`__      | ``getLong``      |
+---------------+-----------------+------------------+
| `float`__     | `REAL`__        | ``getFloat``     |
+---------------+-----------------+------------------+
| `double`__    | `DOUBLE`__      | ``getDouble``    |
+---------------+-----------------+------------------+
| `string`__    | `VARCHAR`__     | ``getString``    |
+---------------+-----------------+------------------+
| `ip`__        | `VARCHAR`__     | ``getString``    |
+---------------+-----------------+------------------+
| `timestamp`__ | `TIMESTAMP`__   | ``getDate``,     |
|               |                 | ``getTime``, or  |
|               |                 | ``getTimestamp`` |
+---------------+-----------------+------------------+
| `geo_point`__ | `ARRAY`__       | ``getArray``     |
+---------------+-----------------+------------------+
| `geo_shape`__ | `JAVA_OBJECT`__ | ``getObject``    |
+---------------+-----------------+------------------+
| `object`__    | `JAVA_OBJECT`__ | ``getObject``    |
+---------------+-----------------+------------------+
| `array`__     | `ARRAY`__       | ``getArray``     |
+---------------+-----------------+------------------+

__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#boolean
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#BOOLEAN
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#numeric-types
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#TINYINT
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#numeric-types
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#SMALLINT
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#numeric-types
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#INTEGER
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#numeric-types
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#BIGINT
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#numeric-types
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#REAL
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#numeric-types
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#DOUBLE
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#character-types
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#VARCHAR
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#ip
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#VARCHAR
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#date-and-time-types
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#TIMESTAMP
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#geo-point
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#ARRAY
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#geo-shape
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#JAVA_OBJECT
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#object
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#JAVA_OBJECT
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#array
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#ARRAY

Array types<commit_msg>Fix broken links in documentation<commit_after>.. _data-types:

==========
Data types
==========

.. rubric:: Table of contents

.. contents::
   :local:

Type mapping
============

JDBC maps SQL types to `Plain Old Java Objects`_ (POJOs).

While this mapping is straightforward for most CrateDB types, for some it is
not.

The following table shows how the CrateDB types are mapped to `JDBC types`_ and
what method can be used to fetch them from a `ResultSet`_ instance:

+---------------+-----------------+------------------+
| CrateDB Type  | JDBC Type       | ResultSet Method |
+===============+=================+==================+
| `boolean`__   | `BOOLEAN`__     | ``getBoolean``   |
+---------------+-----------------+------------------+
| `byte`__      | `TINYINT`__     | ``getByte``      |
+---------------+-----------------+------------------+
| `short`__     | `SMALLINT`__    | ``getShort``     |
+---------------+-----------------+------------------+
| `integer`__   | `INTEGER`__     | ``getInteger``   |
+---------------+-----------------+------------------+
| `long`__      | `BIGINT`__      | ``getLong``      |
+---------------+-----------------+------------------+
| `float`__     | `REAL`__        | ``getFloat``     |
+---------------+-----------------+------------------+
| `double`__    | `DOUBLE`__      | ``getDouble``    |
+---------------+-----------------+------------------+
| `string`__    | `VARCHAR`__     | ``getString``    |
+---------------+-----------------+------------------+
| `ip`__        | `VARCHAR`__     | ``getString``    |
+---------------+-----------------+------------------+
| `timestamp`__ | `TIMESTAMP`__   | ``getDate``,     |
|               |                 | ``getTime``, or  |
|               |                 | ``getTimestamp`` |
+---------------+-----------------+------------------+
| `geo_point`__ | `ARRAY`__       | ``getArray``     |
+---------------+-----------------+------------------+
| `geo_shape`__ | `JAVA_OBJECT`__ | ``getObject``    |
+---------------+-----------------+------------------+
| `object`__    | `JAVA_OBJECT`__ | ``getObject``    |
+---------------+-----------------+------------------+
| `array`__     | `ARRAY`__       | ``getArray``     |
+---------------+-----------------+------------------+

__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#boolean
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#BOOLEAN
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#numeric-data
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#TINYINT
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#numeric-data
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#SMALLINT
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#numeric-data
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#INTEGER
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#numeric-data
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#BIGINT
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#numeric-data
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#REAL
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#numeric-data
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#DOUBLE
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#character-data
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#VARCHAR
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#ip
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#VARCHAR
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#dates-and-times
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#TIMESTAMP
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#geo-point
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#ARRAY
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#geo-shape
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#JAVA_OBJECT
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#object
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#JAVA_OBJECT
__ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#array
__ https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html#ARRAY

Array types
{'fraction_non_alphanumeric': 0.33160229362761007, 'fraction_numerical': 0.0030293194850156877, 'mean_word_length': 1.8743781094527363, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 56, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '752189', 'n_tokens_mistral': 2973, 'n_tokens_neox': 2924, 'n_words': 289}