From 282ec760c151035484b21e5790785aecd4146ef5 Mon Sep 17 00:00:00 2001 From: Ian Li Date: Tue, 24 Oct 2017 18:40:31 -0700 Subject: [PATCH] SPY-1453 1. not caching LogicalRelation 2. adding identifier to LogicalRelation.toString () --- .../datasources/LogicalRelation.scala | 6 ++- .../spark/sql/hive/HiveMetastoreCatalog.scala | 41 +++++++------------ 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/LogicalRelation.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/LogicalRelation.scala index 3813f953e06a3..16719dcd2e789 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/LogicalRelation.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/LogicalRelation.scala @@ -16,6 +16,7 @@ */ package org.apache.spark.sql.execution.datasources +import org.apache.spark.sql.catalyst.TableIdentifier import org.apache.spark.sql.catalyst.analysis.MultiInstanceRelation import org.apache.spark.sql.catalyst.catalog.CatalogTable import org.apache.spark.sql.catalyst.expressions.{AttributeMap, AttributeReference} @@ -69,7 +70,10 @@ case class LogicalRelation( case _ => // Do nothing. } - override def simpleString: String = s"Relation[${Utils.truncatedString(output, ",")}] $relation" + override def simpleString: String = { + s"Relation[${Utils.truncatedString(output, ",")}] $relation " + + s"${catalogTable.map(_.identifier.identifier).getOrElse("")}" + } } object LogicalRelation { diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala index a87aa4877a128..8bde5763375ce 100644 --- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala +++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala @@ -190,33 +190,20 @@ private[hive] class HiveMetastoreCatalog(sparkSession: SparkSession) extends Log } else { selectParquetLocationDirectories(relation.tableMeta.identifier.table, Option(rootPath)) } - withTableCreationLock(tableIdentifier, { - val cached = getCached( - tableIdentifier, - paths, - metastoreSchema, - fileFormatClass, - None) - val logicalRelation = cached.getOrElse { - val (dataSchema, updatedTable) = inferIfNeeded(relation, options, fileFormat) - val created = - LogicalRelation( - DataSource( - sparkSession = sparkSession, - paths = paths.map(_.toString), - userSpecifiedSchema = Option(dataSchema), - // We don't support hive bucketed tables, only ones we write out. - bucketSpec = None, - options = options, - className = fileType).resolveRelation(), - table = updatedTable) - - catalogProxy.cacheTable(tableIdentifier, created) - created - } - - logicalRelation - }) + // SPY-1453: disable the cache completely until we migrated to partitioning + val (dataSchema, updatedTable) = inferIfNeeded(relation, options, fileFormat) + val created = + LogicalRelation( + DataSource( + sparkSession = sparkSession, + paths = paths.map(_.toString), + userSpecifiedSchema = Option(dataSchema), + // We don't support hive bucketed tables, only ones we write out. + bucketSpec = None, + options = options, + className = fileType).resolveRelation(), + table = updatedTable) + created } // The inferred schema may have different field names as the table schema, we should respect // it, but also respect the exprId in table relation output.