blob: 002c3f02c2a9812b2b690ac427592c671581aa0d [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc -->
<title>JsonToRow (Apache Beam 2.47.0)</title>
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="JsonToRow (Apache Beam 2.47.0)";
}
}
catch(err) {
}
//-->
var methods = {"i0":9,"i1":9,"i2":9};
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],8:["t4","Concrete Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/beam/sdk/transforms/InferableFunction.html" title="class in org.apache.beam.sdk.transforms"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../../org/apache/beam/sdk/transforms/JsonToRow.JsonToRowWithErrFn.html" title="class in org.apache.beam.sdk.transforms"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/beam/sdk/transforms/JsonToRow.html" target="_top">Frames</a></li>
<li><a href="JsonToRow.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li><a href="#nested.class.summary">Nested</a>&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.beam.sdk.transforms</div>
<h2 title="Class JsonToRow" class="title">Class JsonToRow</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>org.apache.beam.sdk.transforms.JsonToRow</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre><a href="../../../../../org/apache/beam/sdk/annotations/Experimental.html" title="annotation in org.apache.beam.sdk.annotations">@Experimental</a>(<a href="../../../../../org/apache/beam/sdk/annotations/Experimental.html#value--">value</a>=<a href="../../../../../org/apache/beam/sdk/annotations/Experimental.Kind.html#SCHEMAS">SCHEMAS</a>)
public class <span class="typeNameLabel">JsonToRow</span>
extends java.lang.Object</pre>
<div class="block"><i>Experimental</i>
<p>Creates a <a href="../../../../../org/apache/beam/sdk/transforms/PTransform.html" title="class in org.apache.beam.sdk.transforms"><code>PTransform</code></a> to convert input JSON objects to <a href="../../../../../org/apache/beam/sdk/values/Row.html" title="class in org.apache.beam.sdk.values"><code>Rows</code></a> with given
<a href="../../../../../org/apache/beam/sdk/schemas/Schema.html" title="class in org.apache.beam.sdk.schemas"><code>Schema</code></a>.
<p>Currently supported <a href="../../../../../org/apache/beam/sdk/schemas/Schema.html" title="class in org.apache.beam.sdk.schemas"><code>Schema</code></a> field types are:
<ul>
<li><code>Schema.TypeName#BYTE</code>
<li><code>Schema.TypeName#INT16</code>
<li><code>Schema.TypeName#INT32</code>
<li><code>Schema.TypeName#INT64</code>
<li><code>Schema.TypeName#FLOAT</code>
<li><code>Schema.TypeName#DOUBLE</code>
<li><code>Schema.TypeName#BOOLEAN</code>
<li><code>Schema.TypeName#STRING</code>
</ul>
<p>For specifics of JSON deserialization see <code>RowJson.RowJsonDeserializer</code>.
<p>Conversion is strict, with minimal type coercion:
<p>Booleans are only parsed from <code>true</code> or <code>false</code> literals, not from <code>"true"</code>
or <code>"false"</code> strings or any other values (exception is thrown in these cases).
<p>If a JSON number doesn't fit into the corresponding schema field type, an exception is be
thrown. Strings are not auto-converted to numbers. Floating point numbers are not auto-converted
to integral numbers. Precision loss also causes exceptions.
<p>Only JSON string values can be parsed into <a href="../../../../../org/apache/beam/sdk/schemas/Schema.TypeName.html#STRING"><code>Schema.TypeName.STRING</code></a>. Numbers, booleans are not
automatically converted, exceptions are thrown in these cases.
<p>If a schema field is missing from the JSON value, by default the field will be assumed to have
a null value, and will be converted into a null in the row if the schema has this field being
nullable. This behavior can be changed by setting the <code>RowJson.RowJsonDeserializer.NullBehavior</code> using the <a href="../../../../../org/apache/beam/sdk/transforms/JsonToRow.html#withSchemaAndNullBehavior-org.apache.beam.sdk.schemas.Schema-org.apache.beam.sdk.util.RowJson.RowJsonDeserializer.NullBehavior-"><code>withSchemaAndNullBehavior(org.apache.beam.sdk.schemas.Schema, org.apache.beam.sdk.util.RowJson.RowJsonDeserializer.NullBehavior)</code></a>. For example, setting it with <code>RowJson.RowJsonDeserializer.NullBehavior.REQUIRE_NULL</code> means that JSON values must be null to be parsed as null, otherwise an
error will be thrown, as with previous versions of Beam.</div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== NESTED CLASS SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="nested.class.summary">
<!-- -->
</a>
<h3>Nested Class Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Nested Class Summary table, listing nested classes, and an explanation">
<caption><span>Nested Classes</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Class and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static class&nbsp;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/transforms/JsonToRow.JsonToRowWithErrFn.html" title="class in org.apache.beam.sdk.transforms">JsonToRow.JsonToRowWithErrFn</a></span></code>&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static class&nbsp;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/transforms/JsonToRow.ParseResult.html" title="class in org.apache.beam.sdk.transforms">JsonToRow.ParseResult</a></span></code>
<div class="block">The result of a <a href="../../../../../org/apache/beam/sdk/transforms/JsonToRow.html#withExceptionReporting-org.apache.beam.sdk.schemas.Schema-"><code>withExceptionReporting(Schema)</code></a> transform.</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.summary">
<!-- -->
</a>
<h3>Constructor Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colOne"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/transforms/JsonToRow.html#JsonToRow--">JsonToRow</a></span>()</code>&nbsp;</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code>static <a href="../../../../../org/apache/beam/sdk/transforms/JsonToRow.JsonToRowWithErrFn.html" title="class in org.apache.beam.sdk.transforms">JsonToRow.JsonToRowWithErrFn</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/transforms/JsonToRow.html#withExceptionReporting-org.apache.beam.sdk.schemas.Schema-">withExceptionReporting</a></span>(<a href="../../../../../org/apache/beam/sdk/schemas/Schema.html" title="class in org.apache.beam.sdk.schemas">Schema</a>&nbsp;rowSchema)</code>
<div class="block">Enable Exception Reporting support.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>static <a href="../../../../../org/apache/beam/sdk/transforms/PTransform.html" title="class in org.apache.beam.sdk.transforms">PTransform</a>&lt;<a href="../../../../../org/apache/beam/sdk/values/PCollection.html" title="class in org.apache.beam.sdk.values">PCollection</a>&lt;java.lang.String&gt;,<a href="../../../../../org/apache/beam/sdk/values/PCollection.html" title="class in org.apache.beam.sdk.values">PCollection</a>&lt;<a href="../../../../../org/apache/beam/sdk/values/Row.html" title="class in org.apache.beam.sdk.values">Row</a>&gt;&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/transforms/JsonToRow.html#withSchema-org.apache.beam.sdk.schemas.Schema-">withSchema</a></span>(<a href="../../../../../org/apache/beam/sdk/schemas/Schema.html" title="class in org.apache.beam.sdk.schemas">Schema</a>&nbsp;rowSchema)</code>&nbsp;</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>static <a href="../../../../../org/apache/beam/sdk/transforms/PTransform.html" title="class in org.apache.beam.sdk.transforms">PTransform</a>&lt;<a href="../../../../../org/apache/beam/sdk/values/PCollection.html" title="class in org.apache.beam.sdk.values">PCollection</a>&lt;java.lang.String&gt;,<a href="../../../../../org/apache/beam/sdk/values/PCollection.html" title="class in org.apache.beam.sdk.values">PCollection</a>&lt;<a href="../../../../../org/apache/beam/sdk/values/Row.html" title="class in org.apache.beam.sdk.values">Row</a>&gt;&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/transforms/JsonToRow.html#withSchemaAndNullBehavior-org.apache.beam.sdk.schemas.Schema-org.apache.beam.sdk.util.RowJson.RowJsonDeserializer.NullBehavior-">withSchemaAndNullBehavior</a></span>(<a href="../../../../../org/apache/beam/sdk/schemas/Schema.html" title="class in org.apache.beam.sdk.schemas">Schema</a>&nbsp;rowSchema,
org.apache.beam.sdk.util.RowJson.RowJsonDeserializer.NullBehavior&nbsp;nullBehavior)</code>&nbsp;</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.Object</h3>
<code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a name="JsonToRow--">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>JsonToRow</h4>
<pre>public&nbsp;JsonToRow()</pre>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="withSchema-org.apache.beam.sdk.schemas.Schema-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>withSchema</h4>
<pre>public static&nbsp;<a href="../../../../../org/apache/beam/sdk/transforms/PTransform.html" title="class in org.apache.beam.sdk.transforms">PTransform</a>&lt;<a href="../../../../../org/apache/beam/sdk/values/PCollection.html" title="class in org.apache.beam.sdk.values">PCollection</a>&lt;java.lang.String&gt;,<a href="../../../../../org/apache/beam/sdk/values/PCollection.html" title="class in org.apache.beam.sdk.values">PCollection</a>&lt;<a href="../../../../../org/apache/beam/sdk/values/Row.html" title="class in org.apache.beam.sdk.values">Row</a>&gt;&gt;&nbsp;withSchema(<a href="../../../../../org/apache/beam/sdk/schemas/Schema.html" title="class in org.apache.beam.sdk.schemas">Schema</a>&nbsp;rowSchema)</pre>
</li>
</ul>
<a name="withSchemaAndNullBehavior-org.apache.beam.sdk.schemas.Schema-org.apache.beam.sdk.util.RowJson.RowJsonDeserializer.NullBehavior-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>withSchemaAndNullBehavior</h4>
<pre>public static&nbsp;<a href="../../../../../org/apache/beam/sdk/transforms/PTransform.html" title="class in org.apache.beam.sdk.transforms">PTransform</a>&lt;<a href="../../../../../org/apache/beam/sdk/values/PCollection.html" title="class in org.apache.beam.sdk.values">PCollection</a>&lt;java.lang.String&gt;,<a href="../../../../../org/apache/beam/sdk/values/PCollection.html" title="class in org.apache.beam.sdk.values">PCollection</a>&lt;<a href="../../../../../org/apache/beam/sdk/values/Row.html" title="class in org.apache.beam.sdk.values">Row</a>&gt;&gt;&nbsp;withSchemaAndNullBehavior(<a href="../../../../../org/apache/beam/sdk/schemas/Schema.html" title="class in org.apache.beam.sdk.schemas">Schema</a>&nbsp;rowSchema,
org.apache.beam.sdk.util.RowJson.RowJsonDeserializer.NullBehavior&nbsp;nullBehavior)</pre>
</li>
</ul>
<a name="withExceptionReporting-org.apache.beam.sdk.schemas.Schema-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>withExceptionReporting</h4>
<pre><a href="../../../../../org/apache/beam/sdk/annotations/Experimental.html" title="annotation in org.apache.beam.sdk.annotations">@Experimental</a>(<a href="../../../../../org/apache/beam/sdk/annotations/Experimental.html#value--">value</a>=<a href="../../../../../org/apache/beam/sdk/annotations/Experimental.Kind.html#SCHEMAS">SCHEMAS</a>)
public static&nbsp;<a href="../../../../../org/apache/beam/sdk/transforms/JsonToRow.JsonToRowWithErrFn.html" title="class in org.apache.beam.sdk.transforms">JsonToRow.JsonToRowWithErrFn</a>&nbsp;withExceptionReporting(<a href="../../../../../org/apache/beam/sdk/schemas/Schema.html" title="class in org.apache.beam.sdk.schemas">Schema</a>&nbsp;rowSchema)</pre>
<div class="block">Enable Exception Reporting support. If this value is set errors in the parsing layer are
returned as Row objects within a <a href="../../../../../org/apache/beam/sdk/transforms/JsonToRow.ParseResult.html" title="class in org.apache.beam.sdk.transforms"><code>JsonToRow.ParseResult</code></a>
<p>You can access the results by using <a href="../../../../../org/apache/beam/sdk/transforms/JsonToRow.html#withExceptionReporting-org.apache.beam.sdk.schemas.Schema-"><code>withExceptionReporting(Schema)</code></a>:
<p>ParseResult results = jsonPersons.apply(JsonToRow.withExceptionReporting(PERSON_SCHEMA));
<p>Then access the parsed results via, <a href="../../../../../org/apache/beam/sdk/transforms/JsonToRow.ParseResult.html#getResults--"><code>JsonToRow.ParseResult.getResults()</code></a>
<p>
<p>And access the failed to parse results via, <a href="../../../../../org/apache/beam/sdk/transforms/JsonToRow.ParseResult.html#getFailedToParseLines--"><code>JsonToRow.ParseResult.getFailedToParseLines()</code></a>
<p>
<p>This will produce a Row with Schema <a href="../../../../../org/apache/beam/sdk/transforms/JsonToRow.JsonToRowWithErrFn.html#ERROR_ROW_SCHEMA"><code>JsonToRow.JsonToRowWithErrFn.ERROR_ROW_SCHEMA</code></a>
<p>To access the reason for the failure you will need to first enable extended error reporting.
<a href="../../../../../org/apache/beam/sdk/transforms/JsonToRow.JsonToRowWithErrFn.html#withExtendedErrorInfo--"><code>JsonToRow.JsonToRowWithErrFn.withExtendedErrorInfo()</code></a>
<p>This will provide access to the reason for the Parse failure. The call to <a href="../../../../../org/apache/beam/sdk/transforms/JsonToRow.ParseResult.html#getFailedToParseLines--"><code>JsonToRow.ParseResult.getFailedToParseLines()</code></a> will produce a Row with Schema <a href="../../../../../org/apache/beam/sdk/transforms/JsonToRow.JsonToRowWithErrFn.html#ERROR_ROW_WITH_ERR_MSG_SCHEMA"><code>JsonToRow.JsonToRowWithErrFn.ERROR_ROW_WITH_ERR_MSG_SCHEMA</code></a></div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><a href="../../../../../org/apache/beam/sdk/transforms/JsonToRow.JsonToRowWithErrFn.html" title="class in org.apache.beam.sdk.transforms"><code>JsonToRow.JsonToRowWithErrFn</code></a></dd>
</dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/beam/sdk/transforms/InferableFunction.html" title="class in org.apache.beam.sdk.transforms"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../../org/apache/beam/sdk/transforms/JsonToRow.JsonToRowWithErrFn.html" title="class in org.apache.beam.sdk.transforms"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/beam/sdk/transforms/JsonToRow.html" target="_top">Frames</a></li>
<li><a href="JsonToRow.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li><a href="#nested.class.summary">Nested</a>&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>