Skip to content

Commit

Permalink
alternate the pattern matching order for logical plan:CTAS
Browse files Browse the repository at this point in the history
  • Loading branch information
chenghao-intel committed Dec 11, 2014
1 parent e004895 commit e8cbd56
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ case class CreateTableAsSelect[T](
allowExisting: Boolean,
desc: Option[T] = None) extends UnaryNode {
override def output = Seq.empty[Attribute]
override lazy val resolved = (databaseName != None && childrenResolved)
override lazy val resolved = databaseName != None && childrenResolved
}

case class WriteToFile(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,9 @@ private[hive] class HiveMetastoreCatalog(hive: HiveContext) extends Catalog with
def apply(plan: LogicalPlan): LogicalPlan = plan transform {
// Wait until children are resolved.
case p: LogicalPlan if !p.childrenResolved => p
case p: LogicalPlan if p.resolved => p

// TODO extra is in type of ASTNode which means the logical plan is not resolved
// Need to think about how to implement the CreateTableAsSelect.resolved
case CreateTableAsSelect(db, tableName, child, allowExisting, Some(extra: ASTNode)) =>
val (dbName, tblName) = processDatabaseAndTableName(db, tableName)
val databaseName = dbName.getOrElse(hive.sessionState.getCurrentDatabase)
Expand All @@ -287,7 +288,9 @@ private[hive] class HiveMetastoreCatalog(hive: HiveContext) extends Catalog with

CreateTableAsSelect(Some(databaseName), tblName, child, allowExisting, desc)

case CreateTableAsSelect(db, tableName, child, allowExisting, None) =>
case p: LogicalPlan if p.resolved => p

case p @ CreateTableAsSelect(db, tableName, child, allowExisting, None) =>
val (dbName, tblName) = processDatabaseAndTableName(db, tableName)
val databaseName = dbName.getOrElse(hive.sessionState.getCurrentDatabase)
CreateTableAsSelect(Some(databaseName), tblName, child, allowExisting, None)
Expand Down

0 comments on commit e8cbd56

Please sign in to comment.