Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/17015#discussion_r103383919
--- Diff:
sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveStrategies.scala ---
@@ -91,18 +97,58 @@ class ResolveHiveSerdeTable(session: SparkSession)
extends Rule[LogicalPlan] {
// Infers the schema, if empty, because the schema could be
determined by Hive
// serde.
- val catalogTable = if (query.isEmpty) {
- val withSchema = HiveUtils.inferSchema(withStorage)
- if (withSchema.schema.length <= 0) {
+ val withSchema = if (query.isEmpty) {
+ val inferred = HiveUtils.inferSchema(withStorage)
+ if (inferred.schema.length <= 0) {
throw new AnalysisException("Unable to infer the schema. " +
- s"The schema specification is required to create the table
${withSchema.identifier}.")
+ s"The schema specification is required to create the table
${inferred.identifier}.")
}
- withSchema
+ inferred
} else {
withStorage
}
- c.copy(tableDesc = catalogTable)
+ c.copy(tableDesc = withSchema)
+ }
+}
+
+class DetermineTableStats(session: SparkSession) extends Rule[LogicalPlan]
{
+ override def apply(plan: LogicalPlan): LogicalPlan = plan
resolveOperators {
+ case relation: CatalogRelation
+ if DDLUtils.isHiveTable(relation.tableMeta) &&
relation.tableMeta.stats.isEmpty =>
+ val table = relation.tableMeta
+ // 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.
+ // Besides `totalSize`, there are also `numFiles`, `numRows`,
`rawDataSize` keys
+ // (see StatsSetupConst in Hive) that we can look at in the future.
+ // 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, use
`HiveExternalCatalog.STATISTICS_TOTAL_SIZE`,
--- End diff --
This is out of dated, I think
---
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]