@ 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 . fs = ProxyUtils . getOwnerFs ( state , this . versionOwner ) ; try ( HiveProxyQueryExecutor queryExecutor = ProxyUtils . getQueryExecutor ( state , this . versionOwner ) ) { log . info ( "Trying to clean version " + completeName ) ; if ( ! this . fs . 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 . nonDeletableVersionLocations . contains ( versionLocation . toString ( ) ) ) { log . info ( "This version corresponds to the non deletable version. Won't delete the data but metadata will be dropped for the version " + completeName ) ; } else if ( HadoopUtils . hasContent ( this . fs , versionLocation ) ) { if ( this . simulate ) { log . info ( "Simulate is set to true. Won't delete the partition " + completeName ) ; return ; } log . info ( "Deleting data from the version " + completeName ) ; this . fs . delete ( versionLocation , true ) ; } executeDropVersionQueries ( queryExecutor ) ; } }
If simulate is set to true this will simply return . If version is pointing to an empty location drop the partition and close the jdbc connection . If version is pointing to the same location as of the dataset then drop the partition and close the jdbc connection . If version is pointing to the non deletable version locations then drop the partition and close the jdbc connection . Otherwise delete the data underneath drop the partition and close the jdbc connection .