title: Databricks notebook - return all values from a table
body: <p>For test purposes, I have an empty DB into which I populate a tiny amount of data, extracted and transformed from a json file.</p>
  <p>I would like to create a notebook using scala, which gets all values from all columns from a given table, and exit the notebook returning this result as a string.</p>
  <p>I've tried variations of the following:</p>
  <pre><code>val result = spark.sql(&quot;select * from table.DB&quot;).as[String];
  dbutils.notebook.exit(result)
  </code></pre>
  <p>However the first command fails with error:
  AnalysisException: Try to map struct&lt;Version:bigint,metadataInformation:struct&lt;metadataID:string... etc ...&gt; to Tuple1, but failed as the number of fields does not line up.;</p>
  <p>However, something like the following works, to retrieve value of a specific field, from a column:</p>
  <pre><code>val result = spark.sql(&quot;select column.jsonfield from table.DB&quot;).as[String].first();
  dbutils.notebook.exit(result)
  </code></pre>
  <p>How can I return the content of all columns?</p>