xupefei commented on code in PR #45701:
URL: https://github.com/apache/spark/pull/45701#discussion_r1570681872


##########
connector/connect/common/src/main/scala/org/apache/spark/sql/connect/client/SparkResult.scala:
##########
@@ -198,6 +206,29 @@ private[sql] class SparkResult[T](
     nonEmpty
   }
 
+  private def processObservedMetrics(
+      metrics: java.util.List[ObservedMetrics]): Iterable[(String, Row)] = {
+    metrics.asScala.map { metric =>
+      assert(metric.getKeysCount == metric.getValuesCount)
+      var schema = new StructType()
+      val keys = mutable.ListBuffer.empty[String]
+      val values = mutable.ListBuffer.empty[Any]
+      (0 until metric.getKeysCount).map { i =>
+        val key = metric.getKeys(i)
+        val value = 
LiteralValueProtoConverter.toCatalystValue(metric.getValues(i))
+        schema = schema.add(key, 
LiteralValueProtoConverter.toDataType(value.getClass))

Review Comment:
   I didn't see `.dataType` for the literal `metric.getValues(i)`, only 
`.getLiteralTypeCase`.
   Also to get the actual DataType, we have to look at the values, for example 
for `CalendarInterval`. I think we can't avoid looking at the converted values 
anyway.



-- 
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-unsubscr...@spark.apache.org

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


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

Reply via email to