Skip to content
Snippets Groups Projects
Commit dca6faa2 authored by seayi's avatar seayi Committed by Michael Armbrust
Browse files

[SPARK-5195][sql]Update HiveMetastoreCatalog.scala(override the...

[SPARK-5195][sql]Update HiveMetastoreCatalog.scala(override the MetastoreRelation's sameresult method only compare databasename and table name)

override  the MetastoreRelation's  sameresult method only compare databasename and table name

because in previous :
cache table t1;
select count(*) from t1;
it will read data from memory  but the sql below will not,instead it read from hdfs:
select count(*) from t1 t;

because cache data is keyed by logical plan and compare with sameResult ,so  when table with alias  the same table 's logicalplan is not the same logical plan with out alias  so modify  the sameresult method only compare databasename and table name

Author: seayi <405078363@qq.com>
Author: Michael Armbrust <michael@databricks.com>

Closes #3898 from seayi/branch-1.2 and squashes the following commits:

8f0c7d2 [seayi] Update CachedTableSuite.scala
a277120 [seayi] Update HiveMetastoreCatalog.scala
8d910aa [seayi] Update HiveMetastoreCatalog.scala
parent b1aa8fe9
No related branches found
No related tags found
No related merge requests found
......@@ -519,6 +519,15 @@ private[hive] case class MetastoreRelation
}
)
/** Only compare database and tablename, not alias. */
override def sameResult(plan: LogicalPlan): Boolean = {
plan match {
case mr: MetastoreRelation =>
mr.databaseName == databaseName && mr.tableName == tableName
case _ => false
}
}
val tableDesc = HiveShim.getTableDesc(
Class.forName(
hiveQlTable.getSerializationLib,
......
......@@ -64,6 +64,12 @@ class CachedTableSuite extends QueryTest {
sql("SELECT * FROM src"),
preCacheResults)
assertCached(sql("SELECT * FROM src s"))
checkAnswer(
sql("SELECT * FROM src s"),
preCacheResults)
uncacheTable("src")
assertCached(sql("SELECT * FROM src"), 0)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment