wangyum commented on a change in pull request #24715: [SPARK-25474][SQL] Data
source tables support fallback to HDFS for size estimation
URL: https://github.com/apache/spark/pull/24715#discussion_r315685206
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSourceStrategy.scala
##########
@@ -220,10 +220,20 @@ case class DataSourceAnalysis(conf: SQLConf) extends
Rule[LogicalPlan] with Cast
* data source.
*/
class FindDataSourceTable(sparkSession: SparkSession) extends
Rule[LogicalPlan] {
- private def readDataSourceTable(table: CatalogTable): LogicalPlan = {
- val qualifiedTableName = QualifiedTableName(table.database,
table.identifier.table)
+ private def maybeWithTableStats(tableMeta: CatalogTable): CatalogTable = {
+ if (tableMeta.stats.isEmpty &&
sparkSession.sessionState.conf.fallBackToHdfsForStatsEnabled) {
+ val sizeInBytes =
CommandUtils.getSizeInBytesFallBackToHdfs(sparkSession, tableMeta)
+ tableMeta.copy(stats = Some(CatalogStatistics(sizeInBytes =
BigInt(sizeInBytes))))
+ } else {
+ tableMeta
+ }
+ }
+
+ private def readDataSourceTable(tableMeta: CatalogTable): LogicalPlan = {
+ val qualifiedTableName = QualifiedTableName(tableMeta.database,
tableMeta.identifier.table)
val catalog = sparkSession.sessionState.catalog
catalog.getCachedPlan(qualifiedTableName, () => {
+ val table = maybeWithTableStats(tableMeta)
Review comment:
We cache the table statistics to get better performance.
----------------------------------------------------------------
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]