Datalake table Trash Bin support
The trash bin feature for Datalake tables helps prevent accidental deletion of files and directories when a Datalake table is dropped or when a partition is dropped via ALTER DATALAKE TABLE statement.
This will allow Db2 to provide support for DROP DATALAKE TABLE and ALTER DATALAKE TABLE such that the DELETE DATA clause can be specified without the PURGE option, which will indicate that the data will be removed from the table’s filepath and into a trash bin instead of being completely removed and hence unrecoverable.
When this feature is enabled, and the PURGE option is not used for DROP DATALAKE TABLE or ALTER DATALAKE TABLE, when a file is to be deleted as a result of the DROP or ALTER statement, the files are not immediately removed from the storage. Instead, the deleted files are moved to the /user/<instance-owner>/.Trash/Current directory, with their original filesystem path preserved.
Enabling and disabling trash bin support
By default, the trash bin support is not enabled. To enable this support, the fs.trash.interval configuration parameter must be set to a positive, non-zero value, which indicates how frequently the trash bin should be cleaned. Note that a fs.trash.interval of 0 means that the trash bin feature is disabled.
-
The configuration parameter fs.trash.interval can be configured using the SYSHADOOP.SET_DATALAKE_CONFIG stored procedure to make changes to configuration files. Any value other than 0 will enable the trash bin feature.
enable trash feature:
-
db2 "CALL SYSHADOOP.SET_DATALAKE_CONFIG ('CORE', 'fs.trash.interval', 1440)"
disable trash:
-
db2 "CALL SYSHADOOP.SET_DATALAKE_CONFIG ('CORE', 'fs.trash.interval', null)"
-
Bypassing the trash bin
The auto.purge or skip.trash table property can be used to bypass the trash bin handling for a specific table. If this TBLPROPERTIES value is set to true, when a drop table or alter table drop partition is run with the DELETE DATA clause, the data will not be moved to the trash bin, and will be permanently deleted. See Table Properties, for more information on handling of table properties.