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 2018/12/22 23:24:38 UTC

[GitHub] gatorsmile commented on a change in pull request #19560: [SPARK-22334][SQL] Check table size from filesystem in case the size in metastore is wrong.

gatorsmile commented on a change in pull request #19560: [SPARK-22334][SQL] Check table size from filesystem in case the size in metastore is wrong.
URL: https://github.com/apache/spark/pull/19560#discussion_r243748883
 
 

 ##########
 File path: sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveStrategies.scala
 ##########
 @@ -120,22 +120,53 @@ class DetermineTableStats(session: SparkSession) extends Rule[LogicalPlan] {
         if DDLUtils.isHiveTable(relation.tableMeta) && relation.tableMeta.stats.isEmpty =>
       val table = relation.tableMeta
       val sizeInBytes = if (session.sessionState.conf.fallBackToHdfsForStatsEnabled) {
-        try {
-          val hadoopConf = session.sessionState.newHadoopConf()
-          val tablePath = new Path(table.location)
-          val fs: FileSystem = tablePath.getFileSystem(hadoopConf)
-          fs.getContentSummary(tablePath).getLength
-        } catch {
-          case e: IOException =>
-            logWarning("Failed to get table size from hdfs.", e)
-            session.sessionState.conf.defaultSizeInBytes
-        }
+        getSizeFromFileSystem(table.location)
       } else {
         session.sessionState.conf.defaultSizeInBytes
       }
 
       val withStats = table.copy(stats = Some(CatalogStatistics(sizeInBytes = BigInt(sizeInBytes))))
       relation.copy(tableMeta = withStats)
+
+    case r: Join =>
+      r.transformUp {
+        case relation: HiveTableRelation => verifySize(relation)
+      }
+  }
+
+  private[this] def verifySize(relation: HiveTableRelation): HiveTableRelation = {
 
 Review comment:
   You can add your own customized verification rule by adding a rule into `postHocOptimizationBatches`.
   
   I am close this PR. We will not add this change to the upstream. Thanks for your contributions!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services

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