blob: 33ef1076d21264c6eb168de06693f59c397a7724 [file] [log] [blame]
<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><meta name="description" content="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()."><title>Create type objects — na_type • nanoarrow</title><script src="../deps/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><link href="../deps/bootstrap-5.3.1/bootstrap.min.css" rel="stylesheet"><script src="../deps/bootstrap-5.3.1/bootstrap.bundle.min.js"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous"><!-- bootstrap-toc --><script src="https://cdn.jsdelivr.net/gh/afeld/bootstrap-toc@v1.0.1/dist/bootstrap-toc.min.js" integrity="sha256-4veVQbu7//Lk5TSmc7YV48MxtMy98e26cf5MrgZYnwo=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.11/clipboard.min.js" integrity="sha512-7O5pXpc0oCRrxk8RUfDYFgn0nO1t+jLuIOQdOMRp4APB7uZ4vSjspzp5y6YDtDs4VzUSTbWzBFZ/LKJhnyFOKw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script><!-- search --><script src="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/6.4.6/fuse.js" integrity="sha512-zv6Ywkjyktsohkbp9bb45V6tEMoWhzFzXis+LrMehmJZZSys19Yxf1dopHx7WzIKxr5tK2dVcYmaCk2uqdjF4A==" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/autocomplete.js/0.38.0/autocomplete.jquery.min.js" integrity="sha512-GU9ayf+66Xx2TmpxqJpliWbT5PiGYxpaG8rfnBEk1LL8l1KGkRShhngwdXK1UgqhAzWpZHSiYPc09/NwDQIGyg==" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/mark.min.js" integrity="sha512-5CYOlHXGh6QpOFA/TeTylKLWfB3ftPsde7AnmhuitiTX4K5SqCLBeKro6sPS8ilsz1Q4NRx3v8Ko2IBiszzdww==" crossorigin="anonymous"></script><!-- pkgdown --><script src="../pkgdown.js"></script><meta property="og:title" content="Create type objects — na_type"><meta property="og:description" content="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()."><!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]--></head><body>
<a href="#main" class="visually-hidden-focusable">Skip to contents</a>
<nav class="navbar fixed-top navbar-light navbar-expand-lg bg-light" data-bs-theme="light"><div class="container">
<a class="navbar-brand me-2" href="../index.html">nanoarrow</a>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">0.5.0.9000</small>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div id="navbar" class="collapse navbar-collapse ms-3">
<ul class="navbar-nav me-auto"><li class="active nav-item">
<a class="nav-link" href="../reference/index.html">Reference</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../news/index.html">Changelog</a>
</li>
</ul><form class="form-inline my-2 my-lg-0" role="search">
<input type="search" class="form-control me-sm-2" aria-label="Toggle navigation" name="search-input" data-search-index="../search.json" id="search-input" placeholder="Search for" autocomplete="off"></form>
<ul class="navbar-nav"><li class="nav-item">
<a class="external-link nav-link" href="https://github.com/apache/arrow-nanoarrow/" aria-label="github">
<span class="fab fa fab fa-github fa-lg"></span>
</a>
</li>
</ul></div>
</div>
</nav><div class="container template-reference-topic">
<div class="row">
<main id="main" class="col-md-9"><div class="page-header">
<img src="" class="logo" alt=""><h1>Create type objects</h1>
<small class="dont-index">Source: <a href="https://github.com/apache/arrow-nanoarrow/blob/main/r/R/type.R" class="external-link"><code>R/type.R</code></a></small>
<div class="d-none name"><code>na_type.Rd</code></div>
</div>
<div class="ref-description section level2">
<p>In nanoarrow, types, fields, and schemas are all represented by a
<a href="as_nanoarrow_schema.html">nanoarrow_schema</a>. These functions are convenience
constructors to create these objects in a readable way. Use <code>na_type()</code> to
construct types based on the constructor name, which is also the name that
prints/is returned by <code><a href="as_nanoarrow_schema.html">nanoarrow_schema_parse()</a></code>.</p>
</div>
<div class="section level2">
<h2 id="ref-usage">Usage<a class="anchor" aria-label="anchor" href="#ref-usage"></a></h2>
<div class="sourceCode"><pre class="sourceCode r"><code><span><span class="fu">na_type</span><span class="op">(</span></span>
<span> <span class="va">type_name</span>,</span>
<span> byte_width <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span> unit <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span> timezone <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span> column_types <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span> item_type <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span> key_type <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span> value_type <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span> index_type <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span> ordered <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span> list_size <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span> keys_sorted <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span> storage_type <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span> extension_name <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span> extension_metadata <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span> nullable <span class="op">=</span> <span class="cn">NULL</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_na</span><span class="op">(</span>nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_bool</span><span class="op">(</span>nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_int8</span><span class="op">(</span>nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_uint8</span><span class="op">(</span>nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_int16</span><span class="op">(</span>nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_uint16</span><span class="op">(</span>nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_int32</span><span class="op">(</span>nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_uint32</span><span class="op">(</span>nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_int64</span><span class="op">(</span>nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_uint64</span><span class="op">(</span>nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_half_float</span><span class="op">(</span>nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_float</span><span class="op">(</span>nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_double</span><span class="op">(</span>nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_string</span><span class="op">(</span>nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_large_string</span><span class="op">(</span>nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_binary</span><span class="op">(</span>nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_large_binary</span><span class="op">(</span>nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_fixed_size_binary</span><span class="op">(</span><span class="va">byte_width</span>, nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_date32</span><span class="op">(</span>nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_date64</span><span class="op">(</span>nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_time32</span><span class="op">(</span>unit <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"ms"</span>, <span class="st">"s"</span><span class="op">)</span>, nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_time64</span><span class="op">(</span>unit <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"us"</span>, <span class="st">"ns"</span><span class="op">)</span>, nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_duration</span><span class="op">(</span>unit <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"ms"</span>, <span class="st">"s"</span>, <span class="st">"us"</span>, <span class="st">"ns"</span><span class="op">)</span>, nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_interval_months</span><span class="op">(</span>nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_interval_day_time</span><span class="op">(</span>nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_interval_month_day_nano</span><span class="op">(</span>nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_timestamp</span><span class="op">(</span>unit <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"us"</span>, <span class="st">"ns"</span>, <span class="st">"s"</span>, <span class="st">"ms"</span><span class="op">)</span>, timezone <span class="op">=</span> <span class="st">""</span>, nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_decimal128</span><span class="op">(</span><span class="va">precision</span>, <span class="va">scale</span>, nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_decimal256</span><span class="op">(</span><span class="va">precision</span>, <span class="va">scale</span>, nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_struct</span><span class="op">(</span>column_types <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span><span class="op">)</span>, nullable <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_sparse_union</span><span class="op">(</span>column_types <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_dense_union</span><span class="op">(</span>column_types <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_list</span><span class="op">(</span><span class="va">item_type</span>, nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_large_list</span><span class="op">(</span><span class="va">item_type</span>, nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_fixed_size_list</span><span class="op">(</span><span class="va">item_type</span>, <span class="va">list_size</span>, nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_map</span><span class="op">(</span><span class="va">key_type</span>, <span class="va">item_type</span>, keys_sorted <span class="op">=</span> <span class="cn">FALSE</span>, nullable <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_dictionary</span><span class="op">(</span><span class="va">value_type</span>, index_type <span class="op">=</span> <span class="fu">na_int32</span><span class="op">(</span><span class="op">)</span>, ordered <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">na_extension</span><span class="op">(</span><span class="va">storage_type</span>, <span class="va">extension_name</span>, extension_metadata <span class="op">=</span> <span class="st">""</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level2">
<h2 id="arguments">Arguments<a class="anchor" aria-label="anchor" href="#arguments"></a></h2>
<dl><dt>type_name</dt>
<dd><p>The name of the type (e.g., "int32"). This form of the
constructor is useful for writing tests that loop over many types.</p></dd>
<dt>byte_width</dt>
<dd><p>For <code>na_fixed_size_binary()</code>, the number of bytes
occupied by each item.</p></dd>
<dt>unit</dt>
<dd><p>One of 's' (seconds), 'ms' (milliseconds), 'us' (microseconds),
or 'ns' (nanoseconds).</p></dd>
<dt>timezone</dt>
<dd><p>A string representing a timezone name. The empty string ""
represents a naive point in time (i.e., one that has no associated
timezone).</p></dd>
<dt>column_types</dt>
<dd><p>A <code><a href="https://rdrr.io/r/base/list.html" class="external-link">list()</a></code> of <a href="as_nanoarrow_schema.html">nanoarrow_schema</a>s.</p></dd>
<dt>item_type</dt>
<dd><p>For <code>na_list()</code>, <code>na_large_list()</code>, <code>na_fixed_size_list()</code>,
and <code>na_map()</code>, the <a href="as_nanoarrow_schema.html">nanoarrow_schema</a> representing
the item type.</p></dd>
<dt>key_type</dt>
<dd><p>The <a href="as_nanoarrow_schema.html">nanoarrow_schema</a> representing the
<code>na_map()</code> key type.</p></dd>
<dt>value_type</dt>
<dd><p>The <a href="as_nanoarrow_schema.html">nanoarrow_schema</a> representing the
<code>na_dictionary()</code> or <code>na_map()</code> value type.</p></dd>
<dt>index_type</dt>
<dd><p>The <a href="as_nanoarrow_schema.html">nanoarrow_schema</a> representing the
<code>na_dictionary()</code> index type.</p></dd>
<dt>ordered</dt>
<dd><p>Use <code>TRUE</code> to assert that the order of values in the
dictionary are meaningful.</p></dd>
<dt>list_size</dt>
<dd><p>The number of elements in each item in a
<code>na_fixed_size_list()</code>.</p></dd>
<dt>keys_sorted</dt>
<dd><p>Use <code>TRUE</code> to assert that keys are sorted.</p></dd>
<dt>storage_type</dt>
<dd><p>For <code>na_extension()</code>, the underlying value type.</p></dd>
<dt>extension_name</dt>
<dd><p>For <code>na_extension()</code>, the extension name. This is
typically namespaced separated by dots (e.g., arrow.r.vctrs).</p></dd>
<dt>extension_metadata</dt>
<dd><p>A string or raw vector defining extension metadata.
Most Arrow extension types define extension metadata as a JSON object.</p></dd>
<dt>nullable</dt>
<dd><p>Use <code>FALSE</code> to assert that this field cannot contain
null values.</p></dd>
<dt>precision</dt>
<dd><p>The total number of digits representable by the decimal type</p></dd>
<dt>scale</dt>
<dd><p>The number of digits after the decimal point in a decimal type</p></dd>
</dl></div>
<div class="section level2">
<h2 id="value">Value<a class="anchor" aria-label="anchor" href="#value"></a></h2>
<p>A <a href="as_nanoarrow_schema.html">nanoarrow_schema</a></p>
</div>
<div class="section level2">
<h2 id="ref-examples">Examples<a class="anchor" aria-label="anchor" href="#ref-examples"></a></h2>
<div class="sourceCode"><pre class="sourceCode r"><code><span class="r-in"><span><span class="fu">na_int32</span><span class="op">(</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> &lt;nanoarrow_schema int32&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> $ format : chr "i"</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> $ name : chr ""</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> $ metadata : list()</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> $ flags : int 2</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> $ children : list()</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> $ dictionary: NULL</span>
<span class="r-in"><span><span class="fu">na_struct</span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span>col1 <span class="op">=</span> <span class="fu">na_int32</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> &lt;nanoarrow_schema struct&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> $ format : chr "+s"</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> $ name : chr ""</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> $ metadata : list()</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> $ flags : int 0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> $ children :List of 1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> ..$ col1:&lt;nanoarrow_schema int32&gt;</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> .. ..$ format : chr "i"</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> .. ..$ name : chr "col1"</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> .. ..$ metadata : list()</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> .. ..$ flags : int 2</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> .. ..$ children : list()</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> .. ..$ dictionary: NULL</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> $ dictionary: NULL</span>
<span class="r-in"><span></span></span>
</code></pre></div>
</div>
</main><aside class="col-md-3"><nav id="toc"><h2>On this page</h2>
</nav></aside></div>
<footer><div class="pkgdown-footer-left">
<p>Developed by Dewey Dunnington, Apache Arrow.</p>
</div>
<div class="pkgdown-footer-right">
<p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.0.9.</p>
</div>
</footer></div>
</body></html>