Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ case class InsertIntoHadoopFsRelationCommand(
options = options)

fileIndex.foreach(_.refresh())
catalogTable.foreach { table =>
sparkSession.sharedState.cacheManager.uncacheQuery(sparkSession.table(table.identifier))
Copy link
Copy Markdown
Contributor

@windpiger windpiger Feb 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uncache it or refresh it use refreshByPath?
In this PR

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR can make the behavior consistent with what we did for insertion of Hive serve tables

Copy link
Copy Markdown
Contributor

@windpiger windpiger Feb 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
} else {
logInfo("Skipping insertion into a relation that already exists.")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,4 +634,15 @@ class CachedTableSuite extends QueryTest with SQLTestUtils with SharedSQLContext
assert(getNumInMemoryRelations(cachedPlan2) == 4)
}
}

test("SPARK-19756: drop the table cache after inserting into a data source table") {
withTable("t") {
Seq(1 -> "a").toDF("i", "j").write.saveAsTable("t")
spark.catalog.cacheTable("t")
checkAnswer(spark.table("t"), Row(1, "a"))

sql("INSERT INTO t SELECT 2, 'b'")
checkAnswer(spark.table("t"), Row(1, "a") :: Row(2, "b") :: Nil)
}
}
}