blob: ead9233e0e06263ea88775c81130f5cb3b31e10e [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.io.gcp.bigquery_tools module &mdash; Apache Beam documentation</title>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="index" title="Index"
href="genindex.html"/>
<link rel="search" title="Search" href="search.html"/>
<link rel="top" title="Apache Beam documentation" href="index.html"/>
<link rel="up" title="apache_beam.io.gcp package" href="apache_beam.io.gcp.html"/>
<link rel="next" title="apache_beam.io.gcp.bigtableio module" href="apache_beam.io.gcp.bigtableio.html"/>
<link rel="prev" title="apache_beam.io.gcp.bigquery_io_read_pipeline module" href="apache_beam.io.gcp.bigquery_io_read_pipeline.html"/>
<script src="_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<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 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.internal.html">apache_beam.internal package</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="apache_beam.io.html">apache_beam.io package</a><ul class="current">
<li class="toctree-l2 current"><a class="reference internal" href="apache_beam.io.html#subpackages">Subpackages</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.external.html">apache_beam.io.external package</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.flink.html">apache_beam.io.flink package</a></li>
<li class="toctree-l3 current"><a class="reference internal" href="apache_beam.io.gcp.html">apache_beam.io.gcp package</a><ul class="current">
<li class="toctree-l4"><a class="reference internal" href="apache_beam.io.gcp.html#subpackages">Subpackages</a></li>
<li class="toctree-l4 current"><a class="reference internal" href="apache_beam.io.gcp.html#submodules">Submodules</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="apache_beam.io.html#submodules">Submodules</a></li>
</ul>
</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.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.tools.html">apache_beam.tools 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"><a class="reference internal" href="apache_beam.typehints.html">apache_beam.typehints package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.utils.html">apache_beam.utils 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>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.version.html">apache_beam.version module</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" 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.io.html">apache_beam.io package</a> &raquo;</li>
<li><a href="apache_beam.io.gcp.html">apache_beam.io.gcp package</a> &raquo;</li>
<li>apache_beam.io.gcp.bigquery_tools module</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/apache_beam.io.gcp.bigquery_tools.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.io.gcp.bigquery_tools">
<span id="apache-beam-io-gcp-bigquery-tools-module"></span><h1>apache_beam.io.gcp.bigquery_tools module<a class="headerlink" href="#module-apache_beam.io.gcp.bigquery_tools" title="Permalink to this headline"></a></h1>
<p>Tools used by BigQuery sources and sinks.</p>
<p>Classes, constants and functions in this file are experimental and have no
backwards compatibility guarantees.</p>
<p>These tools include wrappers and clients to interact with BigQuery APIs.</p>
<p>NOTHING IN THIS FILE HAS BACKWARDS COMPATIBILITY GUARANTEES.</p>
<dl class="function">
<dt id="apache_beam.io.gcp.bigquery_tools.default_encoder">
<code class="descclassname">apache_beam.io.gcp.bigquery_tools.</code><code class="descname">default_encoder</code><span class="sig-paren">(</span><em>obj</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#default_encoder"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.default_encoder" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="function">
<dt id="apache_beam.io.gcp.bigquery_tools.get_hashable_destination">
<code class="descclassname">apache_beam.io.gcp.bigquery_tools.</code><code class="descname">get_hashable_destination</code><span class="sig-paren">(</span><em>destination</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#get_hashable_destination"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.get_hashable_destination" title="Permalink to this definition"></a></dt>
<dd><p>Parses a table reference into a (project, dataset, table) tuple.</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"><strong>destination</strong> – Either a TableReference object from the bigquery API.
The object has the following attributes: projectId, datasetId, and
tableId. Or a string representing the destination containing
‘PROJECT:DATASET.TABLE’.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">A string representing the destination containing
‘PROJECT:DATASET.TABLE’.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="apache_beam.io.gcp.bigquery_tools.parse_table_schema_from_json">
<code class="descclassname">apache_beam.io.gcp.bigquery_tools.</code><code class="descname">parse_table_schema_from_json</code><span class="sig-paren">(</span><em>schema_string</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#parse_table_schema_from_json"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.parse_table_schema_from_json" title="Permalink to this definition"></a></dt>
<dd><p>Parse the Table Schema provided as string.</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"><strong>schema_string</strong> – String serialized table schema, should be a valid JSON.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">A TableSchema of the BigQuery export from either the Query or the Table.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="apache_beam.io.gcp.bigquery_tools.parse_table_reference">
<code class="descclassname">apache_beam.io.gcp.bigquery_tools.</code><code class="descname">parse_table_reference</code><span class="sig-paren">(</span><em>table</em>, <em>dataset=None</em>, <em>project=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#parse_table_reference"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.parse_table_reference" title="Permalink to this definition"></a></dt>
<dd><p>Parses a table reference into a (project, dataset, table) tuple.</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 simple">
<li><strong>table</strong> – The ID of the table. The ID must contain only letters
(a-z, A-Z), numbers (0-9), or underscores (_). If dataset argument is None
then the table argument must contain the entire table reference:
‘DATASET.TABLE’ or ‘PROJECT:DATASET.TABLE’. This argument can be a
bigquery.TableReference instance in which case dataset and project are
ignored and the reference is returned as a result. Additionally, for date
partitioned tables, appending ‘$YYYYmmdd’ to the table name is supported,
e.g. ‘DATASET.TABLE$YYYYmmdd’.</li>
<li><strong>dataset</strong> – The ID of the dataset containing this table or null if the table
reference is specified entirely by the table argument.</li>
<li><strong>project</strong> – The ID of the project containing this table or null if the table
reference is specified entirely by the table (and possibly dataset)
argument.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A TableReference object from the bigquery API. The object has the following
attributes: projectId, datasetId, and tableId.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><p class="first last"><code class="xref py py-exc docutils literal"><span class="pre">ValueError</span></code> – if the table reference as a string does not match the expected
format.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="apache_beam.io.gcp.bigquery_tools.BigQueryWrapper">
<em class="property">class </em><code class="descclassname">apache_beam.io.gcp.bigquery_tools.</code><code class="descname">BigQueryWrapper</code><span class="sig-paren">(</span><em>client=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#BigQueryWrapper"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.BigQueryWrapper" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">future.types.newobject.newobject</span></code></p>
<p>BigQuery client wrapper with utilities for querying.</p>
<p>The wrapper is used to organize all the BigQuery integration points and
offer a common place where retry logic for failures can be controlled.
In addition it offers various functions used both in sources and sinks
(e.g., find and create tables, query a table, etc.).</p>
<dl class="attribute">
<dt id="apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.TEMP_TABLE">
<code class="descname">TEMP_TABLE</code><em class="property"> = 'temp_table_'</em><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.TEMP_TABLE" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.TEMP_DATASET">
<code class="descname">TEMP_DATASET</code><em class="property"> = 'temp_dataset_'</em><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.TEMP_DATASET" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.unique_row_id">
<code class="descname">unique_row_id</code><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.unique_row_id" title="Permalink to this definition"></a></dt>
<dd><p>Returns a unique row ID (str) used to avoid multiple insertions.</p>
<p>If the row ID is provided, BigQuery will make a best effort to not insert
the same row multiple times for fail and retry scenarios in which the insert
request may be issued several times. This comes into play for sinks executed
in a local runner.</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">Returns:</th><td class="field-body">a unique row ID string</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.get_query_location">
<code class="descname">get_query_location</code><span class="sig-paren">(</span><em>project_id</em>, <em>query</em>, <em>use_legacy_sql</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#BigQueryWrapper.get_query_location"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.get_query_location" title="Permalink to this definition"></a></dt>
<dd><p>Get the location of tables referenced in a query.</p>
<p>This method returns the location of the first referenced table in the query
and depends on the BigQuery service to provide error handling for
queries that reference tables in multiple locations.</p>
</dd></dl>
<dl class="method">
<dt id="apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.get_table">
<code class="descname">get_table</code><span class="sig-paren">(</span><em>project_id</em>, <em>dataset_id</em>, <em>table_id</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#BigQueryWrapper.get_table"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.get_table" title="Permalink to this definition"></a></dt>
<dd><p>Lookup a table’s metadata object.</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 simple">
<li><strong>client</strong> – bigquery.BigqueryV2 instance</li>
<li><strong>project_id</strong> – table lookup parameter</li>
<li><strong>dataset_id</strong> – table lookup parameter</li>
<li><strong>table_id</strong> – table lookup parameter</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">bigquery.Table instance</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><p class="first last">HttpError if lookup failed.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.get_or_create_dataset">
<code class="descname">get_or_create_dataset</code><span class="sig-paren">(</span><em>project_id</em>, <em>dataset_id</em>, <em>location=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#BigQueryWrapper.get_or_create_dataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.get_or_create_dataset" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.get_table_location">
<code class="descname">get_table_location</code><span class="sig-paren">(</span><em>project_id</em>, <em>dataset_id</em>, <em>table_id</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#BigQueryWrapper.get_table_location"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.get_table_location" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.create_temporary_dataset">
<code class="descname">create_temporary_dataset</code><span class="sig-paren">(</span><em>project_id</em>, <em>location</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#BigQueryWrapper.create_temporary_dataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.create_temporary_dataset" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.clean_up_temporary_dataset">
<code class="descname">clean_up_temporary_dataset</code><span class="sig-paren">(</span><em>project_id</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#BigQueryWrapper.clean_up_temporary_dataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.clean_up_temporary_dataset" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.get_job">
<code class="descname">get_job</code><span class="sig-paren">(</span><em>project</em>, <em>job_id</em>, <em>location=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#BigQueryWrapper.get_job"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.get_job" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.perform_load_job">
<code class="descname">perform_load_job</code><span class="sig-paren">(</span><em>destination</em>, <em>files</em>, <em>job_id</em>, <em>schema=None</em>, <em>write_disposition=None</em>, <em>create_disposition=None</em>, <em>additional_load_parameters=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#BigQueryWrapper.perform_load_job"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.perform_load_job" title="Permalink to this definition"></a></dt>
<dd><p>Starts a job to load data into BigQuery.</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">Returns:</th><td class="field-body">bigquery.JobReference with the information about the job that was started.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.get_or_create_table">
<code class="descname">get_or_create_table</code><span class="sig-paren">(</span><em>project_id</em>, <em>dataset_id</em>, <em>table_id</em>, <em>schema</em>, <em>create_disposition</em>, <em>write_disposition</em>, <em>additional_create_parameters=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#BigQueryWrapper.get_or_create_table"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.get_or_create_table" title="Permalink to this definition"></a></dt>
<dd><p>Gets or creates a table based on create and write dispositions.</p>
<p>The function mimics the behavior of BigQuery import jobs when using the
same create and write dispositions.</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 simple">
<li><strong>project_id</strong> – The project id owning the table.</li>
<li><strong>dataset_id</strong> – The dataset id owning the table.</li>
<li><strong>table_id</strong> – The table id.</li>
<li><strong>schema</strong> – A bigquery.TableSchema instance or None.</li>
<li><strong>create_disposition</strong> – CREATE_NEVER or CREATE_IF_NEEDED.</li>
<li><strong>write_disposition</strong> – WRITE_APPEND, WRITE_EMPTY or WRITE_TRUNCATE.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A bigquery.Table instance if table was found or created.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><p class="first last"><cite>RuntimeError</cite> – For various mismatches between the state of the table and
the create/write dispositions passed in. For example if the table is not
empty and WRITE_EMPTY was specified then an error will be raised since
the table was expected to be empty.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.run_query">
<code class="descname">run_query</code><span class="sig-paren">(</span><em>project_id</em>, <em>query</em>, <em>use_legacy_sql</em>, <em>flatten_results</em>, <em>dry_run=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#BigQueryWrapper.run_query"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.run_query" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.insert_rows">
<code class="descname">insert_rows</code><span class="sig-paren">(</span><em>project_id</em>, <em>dataset_id</em>, <em>table_id</em>, <em>rows</em>, <em>skip_invalid_rows=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#BigQueryWrapper.insert_rows"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.insert_rows" title="Permalink to this definition"></a></dt>
<dd><p>Inserts rows into the specified table.</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 simple">
<li><strong>project_id</strong> – The project id owning the table.</li>
<li><strong>dataset_id</strong> – The dataset id owning the table.</li>
<li><strong>table_id</strong> – The table id.</li>
<li><strong>rows</strong> – A list of plain Python dictionaries. Each dictionary is a row and
each key in it is the name of a field.</li>
<li><strong>skip_invalid_rows</strong> – If there are rows with insertion errors, whether they
should be skipped, and all others should be inserted successfully.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">A tuple (bool, errors). If first element is False then the second element
will be a bigquery.InserttErrorsValueListEntry instance containing
specific errors.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.convert_row_to_dict">
<code class="descname">convert_row_to_dict</code><span class="sig-paren">(</span><em>row</em>, <em>schema</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#BigQueryWrapper.convert_row_to_dict"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.BigQueryWrapper.convert_row_to_dict" title="Permalink to this definition"></a></dt>
<dd><p>Converts a TableRow instance using the schema to a Python dict.</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="apache_beam.io.gcp.bigquery_tools.BigQueryReader">
<em class="property">class </em><code class="descclassname">apache_beam.io.gcp.bigquery_tools.</code><code class="descname">BigQueryReader</code><span class="sig-paren">(</span><em>source</em>, <em>test_bigquery_client=None</em>, <em>use_legacy_sql=True</em>, <em>flatten_results=True</em>, <em>kms_key=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#BigQueryReader"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.BigQueryReader" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="apache_beam.runners.dataflow.native_io.iobase.html#apache_beam.runners.dataflow.native_io.iobase.NativeSourceReader" title="apache_beam.runners.dataflow.native_io.iobase.NativeSourceReader"><code class="xref py py-class docutils literal"><span class="pre">apache_beam.runners.dataflow.native_io.iobase.NativeSourceReader</span></code></a></p>
<p>A reader for a BigQuery source.</p>
</dd></dl>
<dl class="class">
<dt id="apache_beam.io.gcp.bigquery_tools.BigQueryWriter">
<em class="property">class </em><code class="descclassname">apache_beam.io.gcp.bigquery_tools.</code><code class="descname">BigQueryWriter</code><span class="sig-paren">(</span><em>sink</em>, <em>test_bigquery_client=None</em>, <em>buffer_size=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#BigQueryWriter"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.BigQueryWriter" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="apache_beam.runners.dataflow.native_io.iobase.html#apache_beam.runners.dataflow.native_io.iobase.NativeSinkWriter" title="apache_beam.runners.dataflow.native_io.iobase.NativeSinkWriter"><code class="xref py py-class docutils literal"><span class="pre">apache_beam.runners.dataflow.native_io.iobase.NativeSinkWriter</span></code></a></p>
<p>The sink writer for a BigQuerySink.</p>
<dl class="method">
<dt id="apache_beam.io.gcp.bigquery_tools.BigQueryWriter.Write">
<code class="descname">Write</code><span class="sig-paren">(</span><em>row</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#BigQueryWriter.Write"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.BigQueryWriter.Write" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="apache_beam.io.gcp.bigquery_tools.RowAsDictJsonCoder">
<em class="property">class </em><code class="descclassname">apache_beam.io.gcp.bigquery_tools.</code><code class="descname">RowAsDictJsonCoder</code><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#RowAsDictJsonCoder"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.RowAsDictJsonCoder" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="apache_beam.coders.coders.html#apache_beam.coders.coders.Coder" title="apache_beam.coders.coders.Coder"><code class="xref py py-class docutils literal"><span class="pre">apache_beam.coders.coders.Coder</span></code></a></p>
<p>A coder for a table row (represented as a dict) to/from a JSON string.</p>
<p>This is the default coder for sources and sinks if the coder argument is not
specified.</p>
<dl class="method">
<dt id="apache_beam.io.gcp.bigquery_tools.RowAsDictJsonCoder.encode">
<code class="descname">encode</code><span class="sig-paren">(</span><em>table_row</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#RowAsDictJsonCoder.encode"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.RowAsDictJsonCoder.encode" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="apache_beam.io.gcp.bigquery_tools.RowAsDictJsonCoder.decode">
<code class="descname">decode</code><span class="sig-paren">(</span><em>encoded_table_row</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#RowAsDictJsonCoder.decode"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.RowAsDictJsonCoder.decode" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="apache_beam.io.gcp.bigquery_tools.RetryStrategy">
<em class="property">class </em><code class="descclassname">apache_beam.io.gcp.bigquery_tools.</code><code class="descname">RetryStrategy</code><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#RetryStrategy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.RetryStrategy" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">future.types.newobject.newobject</span></code></p>
<dl class="attribute">
<dt id="apache_beam.io.gcp.bigquery_tools.RetryStrategy.RETRY_ALWAYS">
<code class="descname">RETRY_ALWAYS</code><em class="property"> = 'RETRY_ALWAYS'</em><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.RetryStrategy.RETRY_ALWAYS" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="apache_beam.io.gcp.bigquery_tools.RetryStrategy.RETRY_NEVER">
<code class="descname">RETRY_NEVER</code><em class="property"> = 'RETRY_NEVER'</em><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.RetryStrategy.RETRY_NEVER" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="apache_beam.io.gcp.bigquery_tools.RetryStrategy.RETRY_ON_TRANSIENT_ERROR">
<code class="descname">RETRY_ON_TRANSIENT_ERROR</code><em class="property"> = 'RETRY_ON_TRANSIENT_ERROR'</em><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.RetryStrategy.RETRY_ON_TRANSIENT_ERROR" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="staticmethod">
<dt id="apache_beam.io.gcp.bigquery_tools.RetryStrategy.should_retry">
<em class="property">static </em><code class="descname">should_retry</code><span class="sig-paren">(</span><em>strategy</em>, <em>error_message</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#RetryStrategy.should_retry"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.RetryStrategy.should_retry" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="apache_beam.io.gcp.bigquery_tools.AppendDestinationsFn">
<em class="property">class </em><code class="descclassname">apache_beam.io.gcp.bigquery_tools.</code><code class="descname">AppendDestinationsFn</code><span class="sig-paren">(</span><em>destination</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#AppendDestinationsFn"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.AppendDestinationsFn" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="apache_beam.transforms.core.html#apache_beam.transforms.core.DoFn" title="apache_beam.transforms.core.DoFn"><code class="xref py py-class docutils literal"><span class="pre">apache_beam.transforms.core.DoFn</span></code></a></p>
<p>Adds the destination to an element, making it a KV pair.</p>
<p>Outputs a PCollection of KV-pairs where the key is a TableReference for the
destination, and the value is the record itself.</p>
<p>Experimental; no backwards compatibility guarantees.</p>
<dl class="method">
<dt id="apache_beam.io.gcp.bigquery_tools.AppendDestinationsFn.process">
<code class="descname">process</code><span class="sig-paren">(</span><em>element</em>, <em>*side_inputs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/gcp/bigquery_tools.html#AppendDestinationsFn.process"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.gcp.bigquery_tools.AppendDestinationsFn.process" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
</div>
</div>
<div class="articleComments">
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="apache_beam.io.gcp.bigtableio.html" class="btn btn-neutral float-right" title="apache_beam.io.gcp.bigtableio module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="apache_beam.io.gcp.bigquery_io_read_pipeline.html" class="btn btn-neutral" title="apache_beam.io.gcp.bigquery_io_read_pipeline 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/snide/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">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</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/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>