> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kinetica.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Type

> Type — Kinetica Java API

Package [com.gpudb](https://docs.kinetica.com/content/api/java/com/gpudb/package-summary.md)

# Class Type

[java.lang.Object](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html)
com.gpudb.Type

All Implemented Interfaces:`Serializable`

***

public final class Type extends [Object](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html) implements [Serializable](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/Serializable.html)Immutable collection of metadata about a GPUdb type.

See Also:

<ul>
  <li>[Serialized Form](https://docs.kinetica.com/content/api/java/serialized-form.md#com.gpudb.Type)</li>
</ul>

<ul>
  <li>
    ## Nested Class Summary

    Nested Classes

    Modifier and TypeClassDescription`static final class ``Type.Column`

    Immutable collection of metadata about a column that is part of a GPUdb type.
  </li>

  <li>
    ## Constructor Summary

    Constructors

    ConstructorDescription`Type(Type.Column... columns)`

    Creates a [`Type`](https://docs.kinetica.com/content/api/java/com/gpudb/Type) object with the specified column metadata and an empty type label.

    `Type(String typeSchema)`

    Creates a [`Type`](https://docs.kinetica.com/content/api/java/com/gpudb/Type) object with column metadata from an Avro record schema and an empty type label.

    `Type(String label, Type.Column... columns)`

    Creates a [`Type`](https://docs.kinetica.com/content/api/java/com/gpudb/Type) object with the specified metadata.

    `Type(String label, String typeSchema, Map<String,List<String>> properties)`

    Creates a [`Type`](https://docs.kinetica.com/content/api/java/com/gpudb/Type) object with metadata in the format returned from the GPUdb /show/table or /show/types endpoints.

    `Type(String label, List<Type.Column> columns)`

    Creates a [`Type`](https://docs.kinetica.com/content/api/java/com/gpudb/Type) object with the specified metadata.

    `Type(List<Type.Column> columns)`

    Creates a [`Type`](https://docs.kinetica.com/content/api/java/com/gpudb/Type) object with the specified column metadata and an empty type label.
  </li>

  <li>
    ## Method Summary

    All MethodsStatic MethodsInstance MethodsConcrete Methods

    Modifier and TypeMethodDescription`String``create(GPUdb gpudb)`

    Creates a type in GPUdb based on the metadata in the [`Type`](https://docs.kinetica.com/content/api/java/com/gpudb/Type) object and returns the type ID for reference.

    `boolean``equals(Object obj)` `static Type``fromDynamicSchema(String schemaString, ByteBuffer encodedData)`

    Creates a [`Type`](https://docs.kinetica.com/content/api/java/com/gpudb/Type) object with the specified dynamic schema metadata and encoded dynamic table data.

    `static Type``fromTable(GPUdb gpudb, String tableName)`

    Creates a [`Type`](https://docs.kinetica.com/content/api/java/com/gpudb/Type) object containing metadata for the GPUdb type of an existing table in GPUdb.

    `static Type``fromType(GPUdb gpudb, String typeId)`

    Creates a [`Type`](https://docs.kinetica.com/content/api/java/com/gpudb/Type) object containing metadata for an existing type in GPUdb.

    `String``getBaseDefinition()`

    Returns the columns of this type with their Avro base types, as a JSON array of `[name, base type]` pairs, followed by `"nullable"` for a nullable column; e.g., `[["id","long"],["name","string","nullable"]]`.

    `Type.Column``getColumn(int index)`

    Gets the column with the specified index.

    `Type.Column``getColumn(String name)`

    Gets the column with the specified name.

    `int``getColumnCount()`

    Gets the number of columns.

    `int``getColumnIndex(String name)`

    Gets the index of the column with the specified name.

    `List<Type.Column>``getColumns()`

    Gets the list of columns that the type comprises.

    `String``getFullDefinition()`

    Returns the columns of this type with their full types and properties, as a JSON array with one entry per column: the column name, its type, then each of its remaining properties as a separate element; e.g., `[["id","long","primary_key"],["code","char8","primary_key","nullable"],["price","decimal(10,2)"]]`.

    `String``getLabel()`

    Gets the user-defined description string which can be used to differentiate between data with otherwise identical schemas.

    `org.apache.avro.Schema``getSchema()`

    Gets the Avro record schema for the type.

    `int``hashCode()` `Record``newInstance()`

    Creates a new [`Record`](https://docs.kinetica.com/content/api/java/com/gpudb/Record) based on the type.

    `String``toString()` 

    Methods inherited from class java.lang.[Object](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html)
    `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`
  </li>
</ul>

<ul>
  <li>
    ## Constructor Details

    <ul>
      <li>
        ### Type

        public Type<wbr />([Type.Column](https://docs.kinetica.com/content/api/java/com/gpudb/Type.Column.md)... columns)Creates a [`Type`](https://docs.kinetica.com/content/api/java/com/gpudb/Type) object with the specified column metadata and an empty type label.

        Parameters:`columns` - the list of columns that the type comprisesThrows:`IllegalArgumentException` - if no columns are specified
      </li>

      <li>
        ### Type

        public Type<wbr />([List](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html)\<[Type.Column](https://docs.kinetica.com/content/api/java/com/gpudb/Type.Column.md)> columns)Creates a [`Type`](https://docs.kinetica.com/content/api/java/com/gpudb/Type) object with the specified column metadata and an empty type label.

        Parameters:`columns` - the list of columns that the type comprisesThrows:`IllegalArgumentException` - if no columns are specified
      </li>

      <li>
        ### Type

        public Type<wbr />([String](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html) label, [Type.Column](https://docs.kinetica.com/content/api/java/com/gpudb/Type.Column.md)... columns)Creates a [`Type`](https://docs.kinetica.com/content/api/java/com/gpudb/Type) object with the specified metadata.

        Parameters:`label` - a user-defined description string which can be used to differentiate between data with otherwise identical schemas`columns` - the list of columns that the type comprisesThrows:`IllegalArgumentException` - if no columns are specified
      </li>

      <li>
        ### Type

        public Type<wbr />([String](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html) label, [List](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html)\<[Type.Column](https://docs.kinetica.com/content/api/java/com/gpudb/Type.Column.md)> columns)Creates a [`Type`](https://docs.kinetica.com/content/api/java/com/gpudb/Type) object with the specified metadata.

        Parameters:`label` - a user-defined description string which can be used to differentiate between data with otherwise identical schemas`columns` - the list of columns that the type comprisesThrows:`IllegalArgumentException` - if no columns are specified
      </li>

      <li>
        ### Type

        public Type<wbr />([String](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html) typeSchema)Creates a [`Type`](https://docs.kinetica.com/content/api/java/com/gpudb/Type) object with column metadata from an Avro record schema and an empty type label.

        Parameters:`typeSchema` - the Avro record schema for the typeThrows:`IllegalArgumentException` - if `typeSchema` is invalid or contains unsupported field types
      </li>

      <li>
        ### Type

        public Type<wbr />([String](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html) label, [String](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html) typeSchema, [Map](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Map.html)\<[String](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html),<wbr />[List](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html)\<[String](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html)>> properties)Creates a [`Type`](https://docs.kinetica.com/content/api/java/com/gpudb/Type) object with metadata in the format returned from the GPUdb /show/table or /show/types endpoints.

        Parameters:`label` - a user-defined description string which can be used to differentiate between data with otherwise identical schemas`typeSchema` - the Avro record schema for the type`properties` - an optional map of column names to lists of properties that apply to those columnsThrows:`IllegalArgumentException` - if `typeSchema` is invalid or contains unsupported field types, or if any `properties` are invalid
      </li>
    </ul>
  </li>

  <li>
    ## Method Details

    <ul>
      <li>
        ### fromTable

        public static [Type](https://docs.kinetica.com/content/api/java/com/gpudb/Type.md) fromTable<wbr />([GPUdb](https://docs.kinetica.com/content/api/java/com/gpudb/GPUdb.md) gpudb, [String](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html) tableName) throws [GPUdbException](https://docs.kinetica.com/content/api/java/com/gpudb/GPUdbException.md)Creates a [`Type`](https://docs.kinetica.com/content/api/java/com/gpudb/Type) object containing metadata for the GPUdb type of an existing table in GPUdb. Note that this method makes a request to GPUdb to obtain the metadata.

        Parameters:`gpudb` - the [`GPUdb`](https://docs.kinetica.com/content/api/java/com/gpudb/GPUdb) instance from which to obtain the metadata`tableName` - the name of the table in GPUdbReturns:the created [`Type`](https://docs.kinetica.com/content/api/java/com/gpudb/Type) objectThrows:`GPUdbException` - if the table does not exist or is not homogeneous, or if an error occurs during the request for metadata
      </li>

      <li>
        ### fromType

        public static [Type](https://docs.kinetica.com/content/api/java/com/gpudb/Type.md) fromType<wbr />([GPUdb](https://docs.kinetica.com/content/api/java/com/gpudb/GPUdb.md) gpudb, [String](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html) typeId) throws [GPUdbException](https://docs.kinetica.com/content/api/java/com/gpudb/GPUdbException.md)Creates a [`Type`](https://docs.kinetica.com/content/api/java/com/gpudb/Type) object containing metadata for an existing type in GPUdb. Note that this method makes a request to GPUdb to obtain the metadata.

        Parameters:`gpudb` - the [`GPUdb`](https://docs.kinetica.com/content/api/java/com/gpudb/GPUdb) instance from which to obtain the metadata`typeId` - the type ID of the type in GPUdbReturns:the created [`Type`](https://docs.kinetica.com/content/api/java/com/gpudb/Type) objectThrows:`GPUdbException` - if the type does not exist or if an error occurs during the request for metadata
      </li>

      <li>
        ### fromDynamicSchema

        public static [Type](https://docs.kinetica.com/content/api/java/com/gpudb/Type.md) fromDynamicSchema<wbr />([String](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html) schemaString, [ByteBuffer](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/ByteBuffer.html) encodedData) throws [GPUdbException](https://docs.kinetica.com/content/api/java/com/gpudb/GPUdbException.md)Creates a [`Type`](https://docs.kinetica.com/content/api/java/com/gpudb/Type) object with the specified dynamic schema metadata and encoded dynamic table data.

        Parameters:`schemaString` - a String object containing the dynamic schema`encodedData` - the binary encoded data that contains metadata on the dynamic schemaReturns:the created [`Type`](https://docs.kinetica.com/content/api/java/com/gpudb/Type) objectThrows:`GPUdbException` - if an error occurs during the processing of the metadata
      </li>

      <li>
        ### getLabel

        public [String](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html) getLabel()Gets the user-defined description string which can be used to differentiate between data with otherwise identical schemas.

        Returns:the label string
      </li>

      <li>
        ### getColumns

        public [List](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html)\<[Type.Column](https://docs.kinetica.com/content/api/java/com/gpudb/Type.Column.md)> getColumns()Gets the list of columns that the type comprises.

        Returns:the list of columns that the type comprises
      </li>

      <li>
        ### getColumn

        public [Type.Column](https://docs.kinetica.com/content/api/java/com/gpudb/Type.Column.md) getColumn<wbr />(int index)Gets the column with the specified index.

        Parameters:`index` - the column indexReturns:the column with the specified indexThrows:`IndexOutOfBoundsException` - if the specified index is out of range
      </li>

      <li>
        ### getColumn

        public [Type.Column](https://docs.kinetica.com/content/api/java/com/gpudb/Type.Column.md) getColumn<wbr />([String](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html) name)Gets the column with the specified name.

        Parameters:`name` - the column nameReturns:the column with the specified name, or null if no such column exists
      </li>

      <li>
        ### getColumnCount

        public int getColumnCount()Gets the number of columns.

        Returns:the number of columns
      </li>

      <li>
        ### getColumnIndex

        public int getColumnIndex<wbr />([String](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html) name)Gets the index of the column with the specified name.

        Parameters:`name` - the column nameReturns:the index of the column with the specified name, or -1 if no such column exists
      </li>

      <li>
        ### getSchema

        public org.apache.avro.Schema getSchema()Gets the Avro record schema for the type.

        Returns:the Avro record schema for the type
      </li>

      <li>
        ### newInstance

        public [Record](https://docs.kinetica.com/content/api/java/com/gpudb/Record.md) newInstance()Creates a new [`Record`](https://docs.kinetica.com/content/api/java/com/gpudb/Record) based on the type.

        Returns:a new [`Record`](https://docs.kinetica.com/content/api/java/com/gpudb/Record)
      </li>

      <li>
        ### create

        public [String](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html) create<wbr />([GPUdb](https://docs.kinetica.com/content/api/java/com/gpudb/GPUdb.md) gpudb) throws [GPUdbException](https://docs.kinetica.com/content/api/java/com/gpudb/GPUdbException.md)Creates a type in GPUdb based on the metadata in the [`Type`](https://docs.kinetica.com/content/api/java/com/gpudb/Type) object and returns the type ID for reference. If an identical type already exists in GPUdb, the type ID of the existing type will be returned and no new type will be created.

        Parameters:`gpudb` - the [`GPUdb`](https://docs.kinetica.com/content/api/java/com/gpudb/GPUdb) instance in which to create the typeReturns:the type ID of the type in GPUdbThrows:`GPUdbException` - if an error occurs while creating the type
      </li>

      <li>
        ### getBaseDefinition

        public [String](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html) getBaseDefinition()Returns the columns of this type with their Avro base types, as a JSON array of `[name, base type]` pairs, followed by `"nullable"` for a nullable column; e.g., `[["id","long"],["name","string","nullable"]]`. Other column properties are omitted.

        Returns:the base definition of this type
      </li>

      <li>
        ### getFullDefinition

        public [String](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html) getFullDefinition()

        Returns the columns of this type with their full types and properties, as a JSON array with one entry per column: the column name, its type, then each of its remaining properties as a separate element; e.g., `[["id","long","primary_key"],["code","char8","primary_key","nullable"],["price","decimal(10,2)"]]`. This is the column-definition form the server accepts for a request schema, such as the `request_schema_str` option of [`/insert/records`](https://docs.kinetica.com/content/api/java/com/gpudb/GPUdb/insertrecords#insertRecords\(java.lang.String,java.util.List,java.util.Map\)).
        &#x20;A column's type is the property that names it, such as `char16`, `uuid` or `decimal(10,2)`, where it has one, and its Avro base type otherwise; the server accepts only one type per column. This `Type` is not modified.

        Returns:the full definition of this type
      </li>

      <li>
        ### equals

        public boolean equals<wbr />([Object](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html) obj)

        Overrides:`equals` in class `Object`
      </li>

      <li>
        ### hashCode

        public int hashCode()

        Overrides:`hashCode` in class `Object`
      </li>

      <li>
        ### toString

        public [String](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html) toString()

        Overrides:`toString` in class `Object`
      </li>
    </ul>
  </li>
</ul>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.