title: In Scala, why do I need to import something only if I use it as a return type?
body: <p>I use Scala in order to write short Spark scripts, and I noticed something strange. If I want to create a DataFrame and perform operations on it, I don't need to import anything. For instance,</p>
  
  <pre><code>val df = sqlContext.read.json("somePath")
  df.show(false)
  </code></pre>
  
  <p>runs just fine. But if I want to write a method that returns a dataframe, I need to explicitly import the DataFrame class first</p>
  
  <pre><code>import org.apache.spark.sql.DataFrame
  
  def foo(path:String) :  DataFrame = {
      val df = ...
      return df
  }
  </code></pre>