spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yadid <ya...@media.mit.edu>
Subject SPARKSQL problem with implementing Scala's Product interface
Date Thu, 10 Jul 2014 16:02:18 GMT
Hi All,

I have a class with too many variables to be implemented as a case class,
therefor I am using regular class that implements Scala's product interface.
Like so:

class Info () extends Product with Serializable {
    var param1 : String = ""
    var param2 : String = ""  
  ...
    var param38: String = ""

   def canEqual(that: Any) = that.isInstanceOf[Info]
    def productArity = 38
    def productElement(n: Int) = n match {
         case 0 => param1
         case 1 => param2
         ...
         case 37 => param38
        }
}

after registering the table as info when I execute "SELECT * from info" I
get the expected result.
However, when I execute "SELECT param1, param2 from info" I get the
following exception:
Loss was due to
org.apache.spark.sql.catalyst.errors.package$TreeNodeException: No function
to evaluate expression. type: UnresolvedAttribute, tree: 'param1

I guess I must be missing a method in the implementation. Any pointers
appreciated.

Yadid








--
View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/SPARKSQL-problem-with-implementing-Scala-s-Product-interface-tp9311.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.

Mime
View raw message