Re: Accessing rows of a row in Spark

2014-12-15 Thread Mark Hamstra
Looks like you've got one more layer of containment than you intend -- i.e. you've got Row[WrappedArray[Row[(Int, String)]] where you want Row[Row[(Int, String)]]. That's easy to do if somewhere along the line you did something like `val row = Row(collection)` instead of `val row = Row.fromSeq(col

Re: Accessing rows of a row in Spark

2014-12-15 Thread Jerry Lam
Hi Mark, Thank you for helping out. The items I got back from Spark SQL has the type information as follows: scala> items res16: org.apache.spark.sql.Row = [WrappedArray([1,orange],[2,apple])] I tried to iterate the items as you suggested but no luck. Best Regards, Jerry On Mon, Dec 15, 201

Re: Accessing rows of a row in Spark

2014-12-15 Thread Mark Hamstra
scala> val items = Row(1 -> "orange", 2 -> "apple") items: org.apache.spark.sql.catalyst.expressions.Row = [(1,orange),(2,apple)] If you literally want an iterator, then this: scala> items.toIterator.count { case (user_id, name) => user_id == 1 } res0: Int = 1 ...else: scala> items.count

Accessing rows of a row in Spark

2014-12-15 Thread Jerry Lam
Hi spark users, Do you know how to access rows of row? I have a SchemaRDD called user and register it as a table with the following schema: root |-- user_id: string (nullable = true) |-- item: array (nullable = true) ||-- element: struct (containsNull = false) |||-- item_id: stri