You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/03/31 02:39:22 UTC

[GitHub] [spark] AngersZhuuuu commented on a change in pull request #31179: [SPARK-34113][SQL] Use metric data update metadata statistic's size and rowCount

AngersZhuuuu commented on a change in pull request #31179:
URL: https://github.com/apache/spark/pull/31179#discussion_r604554605



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/FileFormatDataWriter.scala
##########
@@ -251,7 +252,18 @@ class DynamicPartitionDataWriter(
       // See a new partition or bucket - write to a new partition dir (or a new bucket file).
       if (isPartitioned && currentPartitionValues != nextPartitionValues) {
         currentPartitionValues = Some(nextPartitionValues.get.copy())
-        statsTrackers.foreach(_.newPartition(currentPartitionValues.get))
+        val partitionSpec: Map[String, String] = description.partitionColumns.map(attr => {
+          val proj = UnsafeProjection.create(Seq(attr), description.partitionColumns)
+          val attrRow = proj(currentPartitionValues.get)
+          val value = if (attrRow.isNullAt(0)) {
+            null
+          } else {
+            Cast(Literal(attrRow.get(0, attr.dataType), attr.dataType),
+              StringType, Some(SQLConf.get.sessionLocalTimeZone)).eval().toString
+          }
+          attr.name -> value

Review comment:
       > this additional projection looks not good for performance.
   
   So should we not do projection here and do this in driver side when update metrics?




-- 
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:
users@infra.apache.org



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