How to "expand" multi-value fields in JSON using SQL in Java (possibly with LATERAL VIEW)?
<p>I'm trying to transform my JSON input from</p>

<pre><code>col1 | col2
row1   [value1, value2]
row2   [value3, value2]
</code></pre>

<p>to</p>

<pre><code>col1 | col2
row1   value1
row1   value2
row2   value3
row2   value2
</code></pre>

<p>Apparently <code>LATERAL VIEW</code> is the way to go, but I can't seem to get it right.</p>

<p>I've been trying the following:</p>

<pre><code>df= sqlContext.sql(
        "SELECT col1, col2" +
        "FROM temptable LATERAL VIEW col2 AS col2"
);
</code></pre>

<p>(Note: the variable <code>sqlContext</code> is actually a <code>HiveContext</code>.)</p>

<p>But this gives me <code>org.apache.spark.sql.AnalysisException: missing EOF at 'LATERAL' near 'temptable ';</code>. What does it mean by End of File?</p>

<p>How can I achieve this in JAVA?</p>