Github user maropu commented on a diff in the pull request: https://github.com/apache/spark/pull/7392#discussion_r34590505 --- Diff: core/src/main/scala/org/apache/spark/TaskContext.scala --- @@ -32,7 +32,13 @@ object TaskContext { */ def get(): TaskContext = taskContext.get - private val taskContext: ThreadLocal[TaskContext] = new ThreadLocal[TaskContext] + /** + * Returns the partition id of currently active TaskContext. It will return 0 + * if there is no active TaskContext for cases like local execution. + */ + def getPartitionId(): Int = Option(taskContext.get).map(_.partitionId).getOrElse(0) --- End diff -- We also need to fix codes for other ids (stageId and attemptId) to return 0 if taskContext not defined?
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org