blob: a067f694bfca5438150dc2b79b059b94d3731522 [file] [log] [blame]
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>apache_beam.typehints.row_type module &mdash; Apache Beam 2.47.0 documentation</title>
<script type="text/javascript" src="_static/js/modernizr.min.js"></script>
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/language_data.js"></script>
<script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="apache_beam.typehints.schema_registry module" href="apache_beam.typehints.schema_registry.html" />
<link rel="prev" title="apache_beam.typehints.pytorch_type_compatibility module" href="apache_beam.typehints.pytorch_type_compatibility.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home"> Apache Beam
</a>
<div class="version">
2.47.0
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="apache_beam.coders.html">apache_beam.coders package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.dataframe.html">apache_beam.dataframe package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.io.html">apache_beam.io package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.metrics.html">apache_beam.metrics package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.ml.html">apache_beam.ml package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.options.html">apache_beam.options package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.portability.html">apache_beam.portability package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.runners.html">apache_beam.runners package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.testing.html">apache_beam.testing package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.transforms.html">apache_beam.transforms package</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="apache_beam.typehints.html">apache_beam.typehints package</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="apache_beam.typehints.html#subpackages">Subpackages</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="apache_beam.typehints.html#submodules">Submodules</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="apache_beam.typehints.arrow_batching_microbenchmark.html">apache_beam.typehints.arrow_batching_microbenchmark module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.typehints.arrow_type_compatibility.html">apache_beam.typehints.arrow_type_compatibility module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.typehints.batch.html">apache_beam.typehints.batch module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.typehints.decorators.html">apache_beam.typehints.decorators module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.typehints.native_type_compatibility.html">apache_beam.typehints.native_type_compatibility module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.typehints.opcodes.html">apache_beam.typehints.opcodes module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.typehints.pandas_type_compatibility.html">apache_beam.typehints.pandas_type_compatibility module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.typehints.pytorch_type_compatibility.html">apache_beam.typehints.pytorch_type_compatibility module</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">apache_beam.typehints.row_type module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.typehints.schema_registry.html">apache_beam.typehints.schema_registry module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.typehints.schemas.html">apache_beam.typehints.schemas module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.typehints.sharded_key_type.html">apache_beam.typehints.sharded_key_type module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.typehints.trivial_inference.html">apache_beam.typehints.trivial_inference module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.typehints.typecheck.html">apache_beam.typehints.typecheck module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.typehints.typehints.html">apache_beam.typehints.typehints module</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.utils.html">apache_beam.utils package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.yaml.html">apache_beam.yaml package</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.error.html">apache_beam.error module</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.pipeline.html">apache_beam.pipeline module</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.pvalue.html">apache_beam.pvalue module</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">Apache Beam</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> &raquo;</li>
<li><a href="apache_beam.typehints.html">apache_beam.typehints package</a> &raquo;</li>
<li>apache_beam.typehints.row_type module</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/apache_beam.typehints.row_type.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="module-apache_beam.typehints.row_type">
<span id="apache-beam-typehints-row-type-module"></span><h1>apache_beam.typehints.row_type module<a class="headerlink" href="#module-apache_beam.typehints.row_type" title="Permalink to this headline"></a></h1>
<dl class="class">
<dt id="apache_beam.typehints.row_type.RowTypeConstraint">
<em class="property">class </em><code class="descclassname">apache_beam.typehints.row_type.</code><code class="descname">RowTypeConstraint</code><span class="sig-paren">(</span><em>fields: Sequence[Tuple[str, type]], user_type, schema_options: Optional[Sequence[Tuple[str, Any]]] = None, field_options: Optional[Dict[str, Sequence[Tuple[str, Any]]]] = None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/typehints/row_type.html#RowTypeConstraint"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.typehints.row_type.RowTypeConstraint" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">apache_beam.typehints.typehints.TypeConstraint</span></code></p>
<p>For internal use only, no backwards comatibility guaratees. See
<a class="reference external" href="https://beam.apache.org/documentation/programming-guide/#schemas-for-pl-types">https://beam.apache.org/documentation/programming-guide/#schemas-for-pl-types</a>
for guidance on creating PCollections with inferred schemas.</p>
<p>Note RowTypeConstraint does not currently store arbitrary functions for
converting to/from the user type. Instead, we only support <code class="docutils literal notranslate"><span class="pre">NamedTuple</span></code>
user types and make the follow assumptions:</p>
<ul class="simple">
<li>The user type can be constructed with field values as arguments in order
(i.e. <code class="docutils literal notranslate"><span class="pre">constructor(*field_values)</span></code>).</li>
<li>Field values can be accessed from instances of the user type by attribute
(i.e. with <code class="docutils literal notranslate"><span class="pre">getattr(obj,</span> <span class="pre">field_name)</span></code>).</li>
</ul>
<p>In the future we will add support for dataclasses
([#22085](<a class="reference external" href="https://github.com/apache/beam/issues/22085">https://github.com/apache/beam/issues/22085</a>)) which also satisfy
these assumptions.</p>
<p>The RowTypeConstraint constructor should not be called directly (even
internally to Beam). Prefer static methods <code class="docutils literal notranslate"><span class="pre">from_user_type</span></code> or
<code class="docutils literal notranslate"><span class="pre">from_fields</span></code>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>fields</strong> – a list of (name, type) tuples, representing the schema inferred
from user_type.</li>
<li><strong>user_type</strong> – constructor for a user type (e.g. NamedTuple class) that is
used to represent this schema in user code.</li>
<li><strong>schema_options</strong> – A list of (key, value) tuples representing schema-level
options.</li>
<li><strong>field_options</strong> – A dictionary representing field-level options. Dictionary
keys are field names, and dictionary values are lists of (key, value)
tuples representing field-level options for that field.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="staticmethod">
<dt id="apache_beam.typehints.row_type.RowTypeConstraint.from_user_type">
<em class="property">static </em><code class="descname">from_user_type</code><span class="sig-paren">(</span><em>user_type: type</em>, <em>schema_options: Optional[Sequence[Tuple[str</em>, <em>Any]]] = None</em>, <em>field_options: Optional[Dict[str</em>, <em>Sequence[Tuple[str</em>, <em>Any]]]] = None</em><span class="sig-paren">)</span> &#x2192; Optional[apache_beam.typehints.row_type.RowTypeConstraint]<a class="reference internal" href="_modules/apache_beam/typehints/row_type.html#RowTypeConstraint.from_user_type"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.typehints.row_type.RowTypeConstraint.from_user_type" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="staticmethod">
<dt id="apache_beam.typehints.row_type.RowTypeConstraint.from_fields">
<em class="property">static </em><code class="descname">from_fields</code><span class="sig-paren">(</span><em>fields: Sequence[Tuple[str, type]], schema_id: Optional[str] = None, schema_options: Optional[Sequence[Tuple[str, Any]]] = None, field_options: Optional[Dict[str, Sequence[Tuple[str, Any]]]] = None, schema_registry: Optional[apache_beam.typehints.schema_registry.SchemaTypeRegistry] = None</em><span class="sig-paren">)</span> &#x2192; apache_beam.typehints.row_type.RowTypeConstraint<a class="reference internal" href="_modules/apache_beam/typehints/row_type.html#RowTypeConstraint.from_fields"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.typehints.row_type.RowTypeConstraint.from_fields" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="apache_beam.typehints.row_type.RowTypeConstraint.user_type">
<code class="descname">user_type</code><a class="headerlink" href="#apache_beam.typehints.row_type.RowTypeConstraint.user_type" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="apache_beam.typehints.row_type.RowTypeConstraint.set_schema_id">
<code class="descname">set_schema_id</code><span class="sig-paren">(</span><em>schema_id</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/typehints/row_type.html#RowTypeConstraint.set_schema_id"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.typehints.row_type.RowTypeConstraint.set_schema_id" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="apache_beam.typehints.row_type.RowTypeConstraint.schema_id">
<code class="descname">schema_id</code><a class="headerlink" href="#apache_beam.typehints.row_type.RowTypeConstraint.schema_id" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="apache_beam.typehints.row_type.RowTypeConstraint.schema_options">
<code class="descname">schema_options</code><a class="headerlink" href="#apache_beam.typehints.row_type.RowTypeConstraint.schema_options" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="apache_beam.typehints.row_type.RowTypeConstraint.field_options">
<code class="descname">field_options</code><span class="sig-paren">(</span><em>field_name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/typehints/row_type.html#RowTypeConstraint.field_options"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.typehints.row_type.RowTypeConstraint.field_options" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="apache_beam.typehints.row_type.RowTypeConstraint.type_check">
<code class="descname">type_check</code><span class="sig-paren">(</span><em>instance</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/typehints/row_type.html#RowTypeConstraint.type_check"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.typehints.row_type.RowTypeConstraint.type_check" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="apache_beam.typehints.row_type.RowTypeConstraint.get_type_for">
<code class="descname">get_type_for</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/typehints/row_type.html#RowTypeConstraint.get_type_for"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.typehints.row_type.RowTypeConstraint.get_type_for" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="apache_beam.typehints.row_type.GeneratedClassRowTypeConstraint">
<em class="property">class </em><code class="descclassname">apache_beam.typehints.row_type.</code><code class="descname">GeneratedClassRowTypeConstraint</code><span class="sig-paren">(</span><em>fields</em>, <em>schema_id: Optional[str] = None</em>, <em>schema_options: Optional[Sequence[Tuple[str</em>, <em>Any]]] = None</em>, <em>field_options: Optional[Dict[str</em>, <em>Sequence[Tuple[str</em>, <em>Any]]]] = None</em>, <em>schema_registry: Optional[apache_beam.typehints.schema_registry.SchemaTypeRegistry] = None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/typehints/row_type.html#GeneratedClassRowTypeConstraint"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.typehints.row_type.GeneratedClassRowTypeConstraint" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="#apache_beam.typehints.row_type.RowTypeConstraint" title="apache_beam.typehints.row_type.RowTypeConstraint"><code class="xref py py-class docutils literal notranslate"><span class="pre">apache_beam.typehints.row_type.RowTypeConstraint</span></code></a></p>
<p>Specialization of RowTypeConstraint which relies on a generated user_type.</p>
<p>Since the generated user_type cannot be pickled, we supply a custom __reduce__
function that will regenerate the user_type.</p>
</dd></dl>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="apache_beam.typehints.schema_registry.html" class="btn btn-neutral float-right" title="apache_beam.typehints.schema_registry module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="apache_beam.typehints.pytorch_type_compatibility.html" class="btn btn-neutral float-left" title="apache_beam.typehints.pytorch_type_compatibility module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>