cloud-fan commented on issue #25306: [SPARK-28573][SQL] Convert 
InsertIntoTable(HiveTableRelation) to DataSource inserting for partitioned table
URL: https://github.com/apache/spark/pull/25306#issuecomment-526181955
 
 
   @advancedxy this a good point. It looks to me that we mess up 2 things:
   1. the table statistics from metastore
   2. the data size statistics from HDFS
   
   For table stats, we have special logic for it in places like 
`CommandUtils.updateTableStats`. However, in `DetermineTableStats`, we get size 
stats from HDFS and set it as table stats, which is incorrect.
   
   My proposal is
   ```
   class HiveTableRelation(..., statsOpt: Option[Statistics] = None) {
     ...
     override def computeStats(): Statistics = {
       tableMeta.stats.map(_.toPlanStats(output, conf.cboEnabled))
         .orElse(statsOpt)
         .getOrElse {
           throw new IllegalStateException("table stats must be specified.")
         }
     }
   }
   ```
   
   And `DetermineTableStats` should set `HiveTableRelation.statsOpt`

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to