title: pass RDD as parameter and return dataframe to a function - scala
body: <p>I am trying to create function which takes string or RDD as an argument but returns dataframe.</p>
  
  <p>Code:</p>
  
  <pre><code>def udf1 (input: String) = {
    val file = sc.textFile(input);
    file.map(p =&gt; Person(
      (p.substring(1, 15)),
       p.substring(16, 20))).toDF()  
  }
  
  def main() { 
    case class Person(id: String, name: String)     
    val df1 = udf1 ("hdfs:\\")
  }
  </code></pre>
  
  <p>but it retuns always rdd. any suggestions?</p>