Data Types¶
This module contains classes for handling the different storage types that occur in databases.
All data type constructors take a nullable: bool
parameter whose default
value is True
.
datatypes
special
¶
Modules¶
core
¶
Classes¶
Binary (Singleton, Variadic)
¶
A type representing a sequence of bytes.
Notes¶
Some databases treat strings and blobs of equally, and some do not.
For example, Impala doesn't make a distinction between string and binary
types but PostgreSQL has a TEXT
type and a BYTEA
type which are
distinct types that have different behavior.
DataType (Annotable, Comparable)
¶
Base class for all data types.
DataType
instances are
immutable.
name: str
property
readonly
¶Return the name of the data type.
cast(self, target, **kwargs)
¶Cast this data type to target
.
castable(self, target, **kwargs)
¶Return whether this data type is castable to target
.
to_pandas(ibis_dtype)
¶Convert ibis dtype to the pandas / numpy alternative
Geography (GeoSpatial)
¶
Geography values.
Geometry (GeoSpatial)
¶
Geometry values.
Int16 (SignedInteger)
¶
Signed 16-bit integers.
Int32 (SignedInteger)
¶
Signed 32-bit integers.
Int64 (SignedInteger)
¶
Signed 64-bit integers.
Int8 (SignedInteger)
¶
Signed 8-bit integers.
JSONB (Binary)
¶
JSON data stored in a binary representation.
This representation eliminates whitespace, duplicate keys, and does not preserve key ordering.
LineString (GeoSpatial)
¶
A sequence of 2 or more points.
MultiLineString (GeoSpatial)
¶
A set of one or more line strings.
MultiPoint (GeoSpatial)
¶
A set of one or more points.
MultiPolygon (GeoSpatial)
¶
A set of one or more polygons.
Point (GeoSpatial)
¶
A point described by two coordinates.
Polygon (GeoSpatial)
¶
A set of one or more closed line strings.
The first line string represents the shape (external ring) and the rest represent holes in that shape (internal rings).
String (Singleton, Variadic)
¶
A type representing a string.
Notes¶
Because of differences in the way different backends handle strings, we cannot assume that strings are UTF-8 encoded.
Struct (DataType)
¶
UInt16 (UnsignedInteger)
¶
Unsigned 16-bit integers.
UInt32 (UnsignedInteger)
¶
Unsigned 32-bit integers.
UInt64 (UnsignedInteger)
¶
Unsigned 64-bit integers.
UInt8 (UnsignedInteger)
¶
Unsigned 8-bit integers.
Functions¶
cast(source, target, **kwargs)
¶
Attempts to implicitly cast from source dtype to target dtype
parse(text)
¶
Parse a type from a str
text
.
The default maxsize
parameter for caching is chosen to cache the most
commonly used types--there are about 30--along with some capacity for less
common but repeatedly-used complex types.
Parameters¶
text The type string to parse
Examples¶
Parse an array type from a string
import ibis import ibis.expr.datatypes as dt dt.parse("array
") Array(value_type=Int64(nullable=True), nullable=True)
You can avoid parsing altogether by constructing objects directly
import ibis import ibis.expr.datatypes as dt ty = dt.parse("array
") ty == dt.Array(dt.int64) True
parse_type(*args, **kwargs)
¶
DEPRECATED: parse_type
is deprecated as of v4.0; use ibis.expr.datatypes.core.parse