na_type: Create type objects

View source: R/type.R

na_typeR Documentation

Create type objects

Description

In nanoarrow, types, fields, and schemas are all represented by a nanoarrow_schema. These functions are convenience constructors to create these objects in a readable way. Use na_type() to construct types based on the constructor name, which is also the name that prints/is returned by nanoarrow_schema_parse().

Usage

na_type(
  type_name,
  byte_width = NULL,
  unit = NULL,
  timezone = NULL,
  column_types = NULL,
  item_type = NULL,
  key_type = NULL,
  value_type = NULL,
  index_type = NULL,
  ordered = NULL,
  list_size = NULL,
  keys_sorted = NULL,
  storage_type = NULL,
  extension_name = NULL,
  extension_metadata = NULL,
  nullable = NULL
)

na_na(nullable = TRUE)

na_bool(nullable = TRUE)

na_int8(nullable = TRUE)

na_uint8(nullable = TRUE)

na_int16(nullable = TRUE)

na_uint16(nullable = TRUE)

na_int32(nullable = TRUE)

na_uint32(nullable = TRUE)

na_int64(nullable = TRUE)

na_uint64(nullable = TRUE)

na_half_float(nullable = TRUE)

na_float(nullable = TRUE)

na_double(nullable = TRUE)

na_string(nullable = TRUE)

na_large_string(nullable = TRUE)

na_binary(nullable = TRUE)

na_large_binary(nullable = TRUE)

na_fixed_size_binary(byte_width, nullable = TRUE)

na_date32(nullable = TRUE)

na_date64(nullable = TRUE)

na_time32(unit = c("ms", "s"), nullable = TRUE)

na_time64(unit = c("us", "ns"), nullable = TRUE)

na_duration(unit = c("ms", "s", "us", "ns"), nullable = TRUE)

na_interval_months(nullable = TRUE)

na_interval_day_time(nullable = TRUE)

na_interval_month_day_nano(nullable = TRUE)

na_timestamp(unit = c("us", "ns", "s", "ms"), timezone = "", nullable = TRUE)

na_decimal128(precision, scale, nullable = TRUE)

na_decimal256(precision, scale, nullable = TRUE)

na_struct(column_types = list(), nullable = FALSE)

na_sparse_union(column_types = list())

na_dense_union(column_types = list())

na_list(item_type, nullable = TRUE)

na_large_list(item_type, nullable = TRUE)

na_fixed_size_list(item_type, list_size, nullable = TRUE)

na_map(key_type, item_type, keys_sorted = FALSE, nullable = TRUE)

na_dictionary(value_type, index_type = na_int32(), ordered = FALSE)

na_extension(storage_type, extension_name, extension_metadata = "")

Arguments

type_name

The name of the type (e.g., "int32"). This form of the constructor is useful for writing tests that loop over many types.

byte_width

For na_fixed_size_binary(), the number of bytes occupied by each item.

unit

One of 's' (seconds), 'ms' (milliseconds), 'us' (microseconds), or 'ns' (nanoseconds).

timezone

A string representing a timezone name. The empty string "" represents a naive point in time (i.e., one that has no associated timezone).

column_types

A list() of nanoarrow_schemas.

item_type

For na_list(), na_large_list(), na_fixed_size_list(), and na_map(), the nanoarrow_schema representing the item type.

key_type

The nanoarrow_schema representing the na_map() key type.

value_type

The nanoarrow_schema representing the na_dictionary() or na_map() value type.

index_type

The nanoarrow_schema representing the na_dictionary() index type.

ordered

Use TRUE to assert that the order of values in the dictionary are meaningful.

list_size

The number of elements in each item in a na_fixed_size_list().

keys_sorted

Use TRUE to assert that keys are sorted.

storage_type

For na_extension(), the underlying value type.

extension_name

For na_extension(), the extension name. This is typically namespaced separated by dots (e.g., arrow.r.vctrs).

extension_metadata

A string or raw vector defining extension metadata. Most Arrow extension types define extension metadata as a JSON object.

nullable

Use FALSE to assert that this field cannot contain null values.

precision

The total number of digits representable by the decimal type

scale

The number of digits after the decimal point in a decimal type

Value

A nanoarrow_schema

Examples

na_int32()
na_struct(list(col1 = na_int32()))


nanoarrow documentation built on June 22, 2024, 9:37 a.m.