[SPARK-2474][SQL] For a registered table in OverrideCatalog, the Analyzer failed to resolve references in the format of "tableName.fieldName"
Please refer to JIRA (https://issues.apache.org/jira/browse/SPARK-2474) for how to reproduce the problem and my understanding of the root cause. Author: Yin Huai <huai@cse.ohio-state.edu> Closes #1406 from yhuai/SPARK-2474 and squashes the following commits: 96b1627 [Yin Huai] Merge remote-tracking branch 'upstream/master' into SPARK-2474 af36d65 [Yin Huai] Fix comment. be86ba9 [Yin Huai] Correct SQL console settings. c43ad00 [Yin Huai] Wrap the relation in a Subquery named by the table name in OverrideCatalog.lookupRelation. a5c2145 [Yin Huai] Support sql/console.
This commit is contained in:
parent
bcd0c30c7e
commit
8af46d5846
|
@ -166,6 +166,9 @@ object SparkBuild extends PomBuild {
|
|||
/* Enable unidoc only for the root spark project */
|
||||
enable(Unidoc.settings)(spark)
|
||||
|
||||
/* Spark SQL Core console settings */
|
||||
enable(SQL.settings)(sql)
|
||||
|
||||
/* Hive console settings */
|
||||
enable(Hive.settings)(hive)
|
||||
|
||||
|
@ -179,6 +182,27 @@ object SparkBuild extends PomBuild {
|
|||
|
||||
}
|
||||
|
||||
object SQL {
|
||||
|
||||
lazy val settings = Seq(
|
||||
|
||||
initialCommands in console :=
|
||||
"""
|
||||
|import org.apache.spark.sql.catalyst.analysis._
|
||||
|import org.apache.spark.sql.catalyst.dsl._
|
||||
|import org.apache.spark.sql.catalyst.errors._
|
||||
|import org.apache.spark.sql.catalyst.expressions._
|
||||
|import org.apache.spark.sql.catalyst.plans.logical._
|
||||
|import org.apache.spark.sql.catalyst.rules._
|
||||
|import org.apache.spark.sql.catalyst.types._
|
||||
|import org.apache.spark.sql.catalyst.util._
|
||||
|import org.apache.spark.sql.execution
|
||||
|import org.apache.spark.sql.test.TestSQLContext._
|
||||
|import org.apache.spark.sql.parquet.ParquetTestData""".stripMargin
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
object Hive {
|
||||
|
||||
lazy val settings = Seq(
|
||||
|
|
|
@ -113,11 +113,12 @@ trait OverrideCatalog extends Catalog {
|
|||
alias: Option[String] = None): LogicalPlan = {
|
||||
val (dbName, tblName) = processDatabaseAndTableName(databaseName, tableName)
|
||||
val overriddenTable = overrides.get((dbName, tblName))
|
||||
val tableWithQualifers = overriddenTable.map(r => Subquery(tblName, r))
|
||||
|
||||
// If an alias was specified by the lookup, wrap the plan in a subquery so that attributes are
|
||||
// properly qualified with this alias.
|
||||
val withAlias =
|
||||
overriddenTable.map(r => alias.map(a => Subquery(a, r)).getOrElse(r))
|
||||
tableWithQualifers.map(r => alias.map(a => Subquery(a, r)).getOrElse(r))
|
||||
|
||||
withAlias.getOrElse(super.lookupRelation(dbName, tblName, alias))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue