title: Calling Dataset static method does not work in Spark Shell
body: <p>I a newbie in Scala, so I apologize in advance if the solution is trivial.</p>
  
  <p>I'm currently trying to execute a query in Spark Shell where I am modifying the logical plan of a dataset. Here is the sample of my code where I am struggling :</p>
  
  <pre><code>import org.apache.spark.sql._
  
  val newPlan = ...
  val newDS = Dataset.ofRows(spark, newPlan)
  </code></pre>
  
  <p>When I am running this, I get the following error message:</p>
  
  <pre><code>&lt;console&gt;:41: error: not found: value Dataset
     val newDS = Dataset.ofRows(spark, newPlan)
  </code></pre>
  
  <p>When trying to specify the package in the declaration:</p>
  
  <pre><code>scala&gt; val newDS = org.apache.spark.sql.Dataset.ofRows(spark, newPlan)
  </code></pre>
  
  <p>I get this:</p>
  
  <pre><code>&lt;console&gt;:41: error: object Dataset in package sql cannot be accessed in package org.apache.spark.sql
         val newDS = org.apache.spark.sql.Dataset.ofRows(spark, newPlan)
  </code></pre>
  
  <p>I also tried <code>import org.apache.spark.sql.Dataset</code>, <code>import org.apache.spark.sql.Dataset._</code> or <code>import org.apache.spark.sql.Dataset.*</code> but none of those worked.</p>
  
  <p>I'm using Spark 2.1.0. Thank you in advance for your help.</p>
  
  <h1>Edit</h1>
  
  <p>The answer is, the <code>ofRows</code> method of the <code>Dataset</code> class is a scala private method. But it is accessible from Java because of the automatic conversion Scala/Java code (and appears in the Javadoc).
  So we are technically not supposed to use this method, but it is accidentally accessible through the Java API.
  I wanted to perform logical plan changes because I am trying to implement run injection-safe dynamic SQL query. But I will try to find a less hacky way for achieving this goal.</p>