@ Override public void clean ( ) throws IOException { Path versionLocation = ( ( HivePartitionRetentionVersion ) this . datasetVersion ) . getLocation ( ) ; Path datasetLocation = ( ( CleanableHivePartitionDataset ) this . cleanableDataset ) . getLocation ( ) ; String completeName = ( ( HivePartitionRetentionVersion ) this . datasetVersion ) . datasetURN ( ) ; State state = new State ( this . state ) ; this . versionOwnerFs = ProxyUtils . getOwnerFs ( state , this . versionOwner ) ; try ( HiveProxyQueryExecutor queryExecutor = ProxyUtils . getQueryExecutor ( state , this . versionOwner , this . backUpOwner ) ) { if ( ! this . versionOwnerFs . exists ( versionLocation ) ) { log . info ( "Data versionLocation doesn't exist. Metadata will be dropped for the version " + completeName ) ; } else if ( datasetLocation . toString ( ) . equalsIgnoreCase ( versionLocation . toString ( ) ) ) { log . info ( "Dataset location is same as version location. Won't delete the data but metadata will be dropped for the version " + completeName ) ; } else if ( this . simulate ) { log . info ( "Simulate is set to true. Won't move the version " + completeName ) ; return ; } else if ( completeName . contains ( ComplianceConfigurationKeys . STAGING ) ) { log . info ( "Deleting data from version " + completeName ) ; this . versionOwnerFs . delete ( versionLocation , true ) ; } else if ( completeName . contains ( ComplianceConfigurationKeys . BACKUP ) ) { executeAlterQueries ( queryExecutor ) ; Path newVersionLocationParent = getNewVersionLocation ( ) . getParent ( ) ; log . info ( "Creating new dir " + newVersionLocationParent . toString ( ) ) ; this . versionOwnerFs . mkdirs ( newVersionLocationParent ) ; log . info ( "Moving data from " + versionLocation + " to " + getNewVersionLocation ( ) ) ; fsMove ( versionLocation , getNewVersionLocation ( ) ) ; FsPermission permission = new FsPermission ( FsAction . ALL , FsAction . ALL , FsAction . NONE ) ; HadoopUtils . setPermissions ( newVersionLocationParent , this . versionOwner , this . backUpOwner , this . versionOwnerFs , permission ) ; } executeDropVersionQueries ( queryExecutor ) ; } }
If simulate is set to true will simply return . If a version is pointing to a non - existing location then drop the partition and close the jdbc connection . If a version is pointing to the same location as of the dataset then drop the partition and close the jdbc connection . If a version is staging it s data will be deleted and metadata is dropped . IF a versions is backup it s data will be moved to a backup dir current metadata will be dropped and it will be registered in the backup db .