File tree Expand file tree Collapse file tree
sql/core/src/main/scala/org/apache/spark/sql/sources Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -262,7 +262,11 @@ private [sql] case class CreateTempTableUsing(
262262 allowExisting : Boolean ) extends RunnableCommand {
263263
264264 def run (sqlContext : SQLContext ) = {
265- if (! sqlContext.catalog.tableExists(Seq (tableName))) {
265+ // The semantic of allowExisting for CREATE TEMPORARY TABLE is if allowExisting is true
266+ // and the table already exists, we will do nothing. If allowExisting is false,
267+ // and the table already exists, we will overwrite it.
268+ val alreadyExists = sqlContext.catalog.tableExists(Seq (tableName))
269+ if (! (alreadyExists && allowExisting)) {
266270 val resolved = ResolvedDataSource (sqlContext, userSpecifiedSchema, provider, options)
267271 sqlContext.registerRDDAsTable(
268272 new DataFrame (sqlContext, LogicalRelation (resolved.relation)), tableName)
You can’t perform that action at this time.
0 commit comments