Skip to content

[SDP] [SPARK-52576] Drop/recreate on full refresh and MV update #51280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
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 @@ -178,12 +178,13 @@ object DatasetManager extends Logging {
}

// Wipe the data if we need to
if ((isFullRefresh || !table.isStreamingTable) && existingTableOpt.isDefined) {
context.spark.sql(s"TRUNCATE TABLE ${table.identifier.quotedString}")
val dropTable = (isFullRefresh || !table.isStreamingTable) && existingTableOpt.isDefined
if (dropTable) {
catalog.dropTable(identifier)
}

// Alter the table if we need to
if (existingTableOpt.isDefined) {
if (existingTableOpt.isDefined && !dropTable) {
val existingSchema = existingTableOpt.get.schema()

val targetSchema = if (table.isStreamingTable && !isFullRefresh) {
Expand All @@ -198,7 +199,7 @@ object DatasetManager extends Logging {
}

// Create the table if we need to
if (existingTableOpt.isEmpty) {
if (dropTable || existingTableOpt.isEmpty) {
catalog.createTable(
identifier,
new TableInfo.Builder()
Expand Down