You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by cloud-fan <gi...@git.apache.org> on 2017/01/13 10:59:19 UTC

[GitHub] spark pull request #14971: [SPARK-17410] [SPARK-17284] Move Hive-generated S...

Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14971#discussion_r95975787
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala ---
    @@ -378,6 +380,50 @@ private[hive] class HiveClientImpl(
     
           val properties = Option(h.getParameters).map(_.asScala.toMap).orNull
     
    +      // Hive-generated Statistics are also recorded in ignoredProperties
    +      val ignoredProperties = scala.collection.mutable.Map.empty[String, String]
    +      properties.collect {
    +        case (key, value) if HiveStatisticsProperties.contains(key) =>
    +          ignoredProperties += (key -> value)
    +      }
    +
    +      val excludedTableProperties = HiveStatisticsProperties ++ Set(
    +        // The property value of "comment" is moved to the dedicated field "comment"
    +        "comment",
    +        // For EXTERNAL_TABLE, the table properties has a particular field "EXTERNAL". This is added
    +        // in the function toHiveTable.
    +        "EXTERNAL"
    +      )
    +
    +      val filteredProperties = properties.filterNot {
    +        case (key, _) => excludedTableProperties.contains(key)
    +      }
    +      val comment = properties.get("comment")
    +
    +      val totalSize = properties.get(StatsSetupConst.TOTAL_SIZE).map(BigInt(_))
    +      val rawDataSize = properties.get(StatsSetupConst.RAW_DATA_SIZE).map(BigInt(_))
    +      val rowCount = properties.get(StatsSetupConst.ROW_COUNT).map(BigInt(_)) match {
    +        case Some(c) if c >= 0 => Some(c)
    +        case _ => None
    +      }
    +      // TODO: check if this estimate is valid for tables after partition pruning.
    +      // NOTE: getting `totalSize` directly from params is kind of hacky, but this should be
    +      // relatively cheap if parameters for the table are populated into the metastore.
    +      // Currently, only totalSize, rawDataSize, and row_count are used to build the field `stats`
    +      // TODO: stats should include all the other two fields (`numFiles` and `numPartitions`).
    +      // (see StatsSetupConst in Hive)
    +      val stats =
    +        // When table is external, `totalSize` is always zero, which will influence join strategy
    +        // so when `totalSize` is zero, use `rawDataSize` instead. When `rawDataSize` is also zero,
    +        // return None. Later, we will use the other ways to estimate the statistics.
    +        if (totalSize.isDefined && totalSize.get > 0L) {
    +          Some(Statistics(sizeInBytes = totalSize.get, rowCount = rowCount))
    +        } else if (rawDataSize.isDefined && rawDataSize.get > 0) {
    +          Some(Statistics(sizeInBytes = rawDataSize.get, rowCount = rowCount))
    +        } else {
    +          None
    --- End diff --
    
    shall we respect `rowCount` in this case?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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