File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed
main/scala/org/apache/spark/sql/pipelines/graph
test/scala/org/apache/spark/sql/pipelines/graph Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -178,12 +178,14 @@ object DatasetManager extends Logging {
178
178
}
179
179
180
180
// Wipe the data if we need to
181
- if ((isFullRefresh || ! table.isStreamingTable) && existingTableOpt.isDefined) {
182
- context.spark.sql(s " TRUNCATE TABLE ${table.identifier.quotedString}" )
181
+ val dropTable = (isFullRefresh || ! table.isStreamingTable) && existingTableOpt.isDefined
182
+ if (dropTable) {
183
+ catalog.dropTable(identifier)
184
+ // context.spark.sql(s"DROP TABLE ${table.identifier.quotedString}")
183
185
}
184
186
185
187
// Alter the table if we need to
186
- if (existingTableOpt.isDefined) {
188
+ if (existingTableOpt.isDefined && ! dropTable ) {
187
189
val existingSchema = existingTableOpt.get.schema()
188
190
189
191
val targetSchema = if (table.isStreamingTable && ! isFullRefresh) {
@@ -198,7 +200,7 @@ object DatasetManager extends Logging {
198
200
}
199
201
200
202
// Create the table if we need to
201
- if (existingTableOpt.isEmpty) {
203
+ if (dropTable || existingTableOpt.isEmpty) {
202
204
catalog.createTable(
203
205
identifier,
204
206
new TableInfo .Builder ()
Original file line number Diff line number Diff line change @@ -434,8 +434,9 @@ class MaterializeTablesSuite extends BaseCoreExecutionTest {
434
434
435
435
val table2 = catalog.loadTable(identifier)
436
436
assert(
437
- table2.columns() sameElements CatalogV2Util
438
- .structTypeToV2Columns(new StructType ().add(" y" , IntegerType ).add(" x" , BooleanType ))
437
+ table2.columns().toSet == CatalogV2Util
438
+ .structTypeToV2Columns(new StructType ().add(" x" , BooleanType ).add(" y" , IntegerType ))
439
+ .toSet
439
440
)
440
441
assert(table2.partitioning().toSeq == Seq (Expressions .identity(" x" )))
441
442
@@ -456,8 +457,9 @@ class MaterializeTablesSuite extends BaseCoreExecutionTest {
456
457
457
458
val table3 = catalog.loadTable(identifier)
458
459
assert(
459
- table3.columns() sameElements CatalogV2Util
460
- .structTypeToV2Columns(new StructType ().add(" y" , IntegerType ).add(" x" , BooleanType ))
460
+ table3.columns().toSet == CatalogV2Util
461
+ .structTypeToV2Columns(new StructType ().add(" x" , BooleanType ).add(" y" , IntegerType ))
462
+ .toSet
461
463
)
462
464
assert(table3.partitioning().toSeq == Seq (Expressions .identity(" x" )))
463
465
}
You can’t perform that action at this time.
0 commit comments