srowen commented on a change in pull request #24992: [SPARK-28194][SQL] 
Refactor code to prevent None.get in EnsureRequirements
URL: https://github.com/apache/spark/pull/24992#discussion_r298815400
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/exchange/EnsureRequirements.scala
 ##########
 @@ -231,14 +231,15 @@ case class EnsureRequirements(conf: SQLConf) extends 
Rule[SparkPlan] {
     val keysAndIndexes = currentOrderOfKeys.zipWithIndex
 
     expectedOrderOfKeys.foreach(expression => {
-      val index = keysAndIndexes.find { case (e, idx) =>
+      keysAndIndexes.find { case (e, idx) =>
         // As we may have the same key used many times, we need to filter out 
its occurrence we
         // have already used.
         e.semanticEquals(expression) && !pickedIndexes.contains(idx)
-      }.map(_._2).get
-      pickedIndexes += index
-      leftKeysBuffer.append(leftKeys(index))
-      rightKeysBuffer.append(rightKeys(index))
+      }.map(_._2).map(index => {
 
 Review comment:
   This has to be `foreach`, not `map`, and can be `.foreach { index =>`
   However I wonder if there's some other bug if the code really doesn't expect 
to not find a value?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to