Source:
private void export_meta_data(PreDropTableEvent tableEvent) throws MetaException { FileSystem fs = null; Table tbl = tableEvent.getTable(); String name = tbl.getTableName(); org.apache.hadoop.hive.ql.metadata.Table mTbl = new org.apache.hadoop.hive.ql.metadata.Table( tbl); IHMSHandler handler = tableEvent.getHandler(); Configuration conf = handler.getConf(); Warehouse wh = new Warehouse(conf); Path tblPath = new Path(tbl.getSd().getLocation()); fs = wh.getFs(tblPath); Date now = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); String dateString = sdf.format(now); String exportPathString = MetastoreConf.getVar(conf, MetastoreConf.ConfVars.METADATA_EXPORT_LOCATION); boolean moveMetadataToTrash = MetastoreConf .getBoolVar(conf, MetastoreConf.ConfVars.MOVE_EXPORTED_METADATA_TO_TRASH); Path exportPath = null; if (exportPathString != null && exportPathString.length() == 0) { exportPath = fs.getHomeDirectory(); } else { exportPath = new Path(exportPathString); } Path metaPath = new Path(exportPath, name + "." + dateString); LOG.info("Exporting the metadata of table " + tbl.toString() + " to path " + metaPath.toString()); try { fs.mkdirs(metaPath); } catch (IOException e) { throw new MetaException(e.getMessage()); } Path outFile = new Path(metaPath, name + EximUtil.METADATA_NAME); try { SessionState.getConsole().printInfo("Beginning metadata export"); EximUtil.createExportDump(fs, outFile, mTbl, null, null, new HiveConf(conf, MetaDataExportListener.class)); if (moveMetadataToTrash == true) { wh.deleteDir(metaPath, true, Hive.get().getDatabase(tbl.getDbName())); } } catch (IOException | MetaException | HiveException e) { throw new MetaException(e.getMessage()); } }

Target:
private void export_meta_data(PreDropTableEvent tableEvent) throws MetaException { FileSystem fs = null; Table tbl = tableEvent.getTable(); String name = tbl.getTableName(); org.apache.hadoop.hive.ql.metadata.Table mTbl = new org.apache.hadoop.hive.ql.metadata.Table( tbl); IHMSHandler handler = tableEvent.getHandler(); Configuration conf = handler.getConf(); Warehouse wh = new Warehouse(conf); Path tblPath = new Path(tbl.getSd().getLocation()); fs = wh.getFs(tblPath); Date now = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); String dateString = sdf.format(now); String exportPathString = MetastoreConf.getVar(conf, MetastoreConf.ConfVars.METADATA_EXPORT_LOCATION); boolean moveMetadataToTrash = MetastoreConf .getBoolVar(conf, MetastoreConf.ConfVars.MOVE_EXPORTED_METADATA_TO_TRASH); Path exportPath = null; if (exportPathString != null && exportPathString.length() == 0) { exportPath = fs.getHomeDirectory(); } else { exportPath = new Path(exportPathString); } Path metaPath = new Path(exportPath, name + "." + dateString); LOG.info("Exporting the metadata of table " + tbl.toString() + " to path " + metaPath.toString()); try { fs.mkdirs(metaPath); } catch (IOException e) { throw new MetaException(e.getMessage()); } Path outFile = new Path(metaPath, name + EximUtil.METADATA_NAME); try { SessionState.getConsole().printInfo("Beginning metadata export"); EximUtil.createExportDump(fs, outFile, mTbl, null, null, new HiveConf(conf, MetaDataExportListener.class)); if (moveMetadataToTrash == true) { wh.deleteDir(metaPath, true, false, false); } } catch (IOException | SemanticException e) { throw new MetaException(e.getMessage()); } }