Skip to content
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 @@ -3116,16 +3116,17 @@ abstract class DDLSuite extends QueryTest with SQLTestUtils {
.getTableMetadata(TableIdentifier("tab1")).storage.locationUri.get)

val fs = tablePath.getFileSystem(hadoopConf)
val trashRoot = fs.getTrashRoot(tablePath)
assert(!fs.exists(trashRoot))
val trashCurrent = new Path(fs.getTrashRoot(tablePath), "Current")
Copy link
Member

@HyukjinKwon HyukjinKwon Aug 26, 2020

Choose a reason for hiding this comment

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

Can we make a fake file system (that extends FileSystem) and use a temporary directory?

Copy link
Member

Choose a reason for hiding this comment

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

+1 for @HyukjinKwon 's suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hii @HyukjinKwon, but Trash.moveToAppropriateTrash will always move the data to trashCurrent. can you guide me on what you mean by using a temporary directory instead.

val trashPath = Path.mergePaths(trashCurrent, tablePath)
assert(!fs.exists(trashPath))
try {
hadoopConf.set(trashIntervalKey, "5")
sql("TRUNCATE TABLE tab1")
} finally {
hadoopConf.set(trashIntervalKey, originalValue)
}
assert(fs.exists(trashRoot))
fs.delete(trashRoot, true)
assert(fs.exists(trashPath))
fs.delete(trashPath, true)
}
}
}
Expand All @@ -3144,15 +3145,16 @@ abstract class DDLSuite extends QueryTest with SQLTestUtils {
.getTableMetadata(TableIdentifier("tab1")).storage.locationUri.get)

val fs = tablePath.getFileSystem(hadoopConf)
val trashRoot = fs.getTrashRoot(tablePath)
assert(!fs.exists(trashRoot))
val trashCurrent = new Path(fs.getTrashRoot(tablePath), "Current")
val trashPath = Path.mergePaths(trashCurrent, tablePath)
assert(!fs.exists(trashPath))
try {
hadoopConf.set(trashIntervalKey, "0")
sql("TRUNCATE TABLE tab1")
} finally {
hadoopConf.set(trashIntervalKey, originalValue)
}
assert(!fs.exists(trashRoot))
assert(!fs.exists(trashPath))
}
}
}
Expand All @@ -3167,9 +3169,10 @@ abstract class DDLSuite extends QueryTest with SQLTestUtils {
.getTableMetadata(TableIdentifier("tab1")).storage.locationUri.get)

val fs = tablePath.getFileSystem(hadoopConf)
val trashRoot = fs.getTrashRoot(tablePath)
val trashCurrent = new Path(fs.getTrashRoot(tablePath), "Current")
val trashPath = Path.mergePaths(trashCurrent, tablePath)
sql("TRUNCATE TABLE tab1")
assert(!fs.exists(trashRoot))
assert(!fs.exists(trashPath))
}
}
}
Expand Down