Skip to content

Commit 065687f

Browse files
committed
address review comments
1 parent d8fca00 commit 065687f

4 files changed

Lines changed: 14 additions & 10 deletions

File tree

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,8 @@ case class UnresolvedRegex(regexPattern: String, table: Option[String], caseSens
345345
// If there is no table specified, use all input attributes that match expr
346346
case None => input.output.filter(_.name.matches(pattern))
347347
// If there is a table, pick out attributes that are part of this table that match expr
348-
case Some(t) => input.output.filter(a => resolver(a.qualifier.last, t)).
349-
filter(_.name.matches(pattern))
348+
case Some(t) => input.output.filter(a => a.qualifier.nonEmpty &&
349+
resolver(a.qualifier.last, t)).filter(_.name.matches(pattern))
350350
}
351351
}
352352

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -692,11 +692,9 @@ class SessionCatalog(
692692
synchronized {
693693
val db = formatDatabaseName(name.database.getOrElse(currentDb))
694694
val table = formatTableName(name.table)
695-
// To keep track of the name and database of the table/view
696-
val alias = AliasIdentifier(table, Some(db))
697695
if (db == globalTempViewManager.database) {
698696
globalTempViewManager.get(table).map { viewDef =>
699-
SubqueryAlias(alias, viewDef)
697+
SubqueryAlias(table, Some(db), viewDef)
700698
}.getOrElse(throw new NoSuchTableException(db, table))
701699
} else if (name.database.isDefined || !tempViews.contains(table)) {
702700
val metadata = externalCatalog.getTable(db, table)
@@ -709,9 +707,9 @@ class SessionCatalog(
709707
desc = metadata,
710708
output = metadata.schema.toAttributes,
711709
child = parser.parsePlan(viewText))
712-
SubqueryAlias(alias, child)
710+
SubqueryAlias(table, Some(db), child)
713711
} else {
714-
SubqueryAlias(alias, UnresolvedCatalogRelation(metadata))
712+
SubqueryAlias(table, Some(db), UnresolvedCatalogRelation(metadata))
715713
}
716714
} else {
717715
SubqueryAlias(table, tempViews(table))

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,13 @@ object SubqueryAlias {
818818
child: LogicalPlan): SubqueryAlias = {
819819
SubqueryAlias(AliasIdentifier(identifier), child)
820820
}
821+
822+
def apply(
823+
identifier: String,
824+
database: Option[String],
825+
child: LogicalPlan): SubqueryAlias = {
826+
SubqueryAlias(AliasIdentifier(identifier, database), child)
827+
}
821828
}
822829
/**
823830
* Sample the dataset.

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalogSuite.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,13 +536,12 @@ abstract class SessionCatalogSuite extends AnalysisTest {
536536
assert(metadata.viewText.isDefined)
537537
val view = View(desc = metadata, output = metadata.schema.toAttributes,
538538
child = CatalystSqlParser.parsePlan(metadata.viewText.get))
539-
val alias = AliasIdentifier("view1", Some("db3"))
540539
comparePlans(catalog.lookupRelation(TableIdentifier("view1", Some("db3"))),
541-
SubqueryAlias(alias, view))
540+
SubqueryAlias("view1", Some("db3"), view))
542541
// Look up a view using current database of the session catalog.
543542
catalog.setCurrentDatabase("db3")
544543
comparePlans(catalog.lookupRelation(TableIdentifier("view1")),
545-
SubqueryAlias(alias, view))
544+
SubqueryAlias("view1", Some("db3"), view))
546545
}
547546
}
548547

0 commit comments

Comments
 (0)