Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/14971#discussion_r117158531
--- Diff:
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala
---
@@ -414,6 +415,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]
+ for (key <- HiveStatisticsProperties; value <- properties.get(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(_))
+ def 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) {
--- End diff --
the indention is wrong
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]