title: Spark: Length of List Tuple
body: <p>What is wrong with my code?</p>
  
  <pre><code>idAndNumbers = ((1,(1,2,3)))
  irRDD = sc.parallelize(idAndNumbers)
  irLengthRDD = irRDD.map(lambda x:x[1].length).collect()
  </code></pre>
  
  <p>Getting bunch of errors like:</p>
  
  <pre><code>Py4JJavaError: An error occurred while calling z:org.apache.spark.api.python.PythonRDD.collectAndServe.:org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 88.0 failed 1 times, most recent failure: Lost task 0.0 in stage 88.0 (TID 88, localhost): org.apache.spark.api.python.PythonException: Traceback (most recent call last):
  </code></pre>
  
  <h3>Edit</h3>
  
  <p>Full trace:</p>
  
  <pre><code>Py4JJavaError: An error occurred while calling z:org.apache.spark.api.python.PythonRDD.collectAndServe.
  : org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 88.0 failed 1 times, most recent failure: Lost task 0.0 in stage 88.0 (TID 88, localhost): org.apache.spark.api.python.PythonException: Traceback (most recent call last):
    File "/usr/local/bin/spark-1.3.1-bin-hadoop2.6/python/pyspark/worker.py", line 101, in main
      process()
    File "/usr/local/bin/spark-1.3.1-bin-hadoop2.6/python/pyspark/worker.py", line 96, in process
      serializer.dump_stream(func(split_index, iterator), outfile)
    File "/usr/local/bin/spark-1.3.1-bin-hadoop2.6/python/pyspark/serializers.py", line 236, in dump_stream
      vs = list(itertools.islice(iterator, batch))
    File "&lt;ipython-input-79-ef1d5a130db5&gt;", line 12, in &lt;lambda&gt;
  TypeError: 'int' object has no attribute '__getitem__'
  
      at org.apache.spark.api.python.PythonRDD$$anon$1.read(PythonRDD.scala:135)
      at org.apache.spark.api.python.PythonRDD$$anon$1.&lt;init&gt;(PythonRDD.scala:176)
      at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:94)
      at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:277)
      at org.apache.spark.rdd.RDD.iterator(RDD.scala:244)
      at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:61)
      at org.apache.spark.scheduler.Task.run(Task.scala:64)
      at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:203)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  
  <h3>Edit 2:</h3>
  
  <p>Turns out it is indeed a nested tuple what I am dealing with like so : <code>((1,(1,2,3)))</code></p>