You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "viirya (via GitHub)" <gi...@apache.org> on 2025/11/20 03:12:27 UTC

Re: [PR] [MINOR][SQL] Remove unused method from Observation [spark]

viirya commented on code in PR #53138:
URL: https://github.com/apache/spark/pull/53138#discussion_r2544193950


##########
sql/api/src/main/scala/org/apache/spark/sql/Observation.scala:
##########
@@ -94,18 +94,6 @@ class Observation(val name: String) {
   @throws[InterruptedException]
   def getAsJava: java.util.Map[String, Any] = get.asJava
 
-  /**
-   * Get the observed metrics. This returns the metrics if they are available, otherwise an empty.
-   *
-   * @return
-   *   the observed metrics as a `Map[String, Any]`
-   */
-  @throws[InterruptedException]
-  private[sql] def getOrEmpty: Map[String, Any] = {
-    val row = getRowOrEmpty.getOrElse(Row.empty)
-    row.getValuesMap(row.schema.map(_.name))

Review Comment:
   There is a bug. If `getRowOrEmpty.getOrElse(Row.empty)` returns `Row.empty`, the next line `row.schema.map(_.name)` will throw NPE because `row.schema` is null.
   
   Since this method is not used, just remove it.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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