Source:
private static void dumpDatabase(TajoClient client, String databaseName, PrintWriter writer) throws SQLException, ServiceException { writer.write("\n"); writer.write("--\n"); writer.write(String.format("-- Database name: %s%n", CatalogUtil.denormalizeIdentifier(databaseName))); writer.write("--\n"); writer.write("\n"); writer.write(String.format("CREATE DATABASE IF NOT EXISTS %s;", CatalogUtil.denormalizeIdentifier(databaseName))); writer.write("\n\n"); List<String> tableNames = new ArrayList<>(); tableNames.addAll(client.getTableList(databaseName)); Collections.sort(tableNames); for (String tableName : tableNames) { try { String fqName = CatalogUtil.buildFQName(databaseName, tableName); TableDesc table = client.getTableDesc(fqName); if (table.getMeta().getDataFormat().equalsIgnoreCase("SYSTEM")) { continue; } if (table.isExternal()) { writer.write(DDLBuilder.buildDDLForExternalTable(table)); } else { writer.write(DDLBuilder.buildDDLForBaseTable(table)); } if (table.hasPartition()) { writer.write("\n\n"); writer.write("--\n"); writer.write(String.format("-- Table Partitions: %s%n", tableName)); writer.write("--\n"); writer.write(String.format("ALTER TABLE %s REPAIR PARTITION;", CatalogUtil.denormalizeIdentifier(databaseName) + "." + CatalogUtil.denormalizeIdentifier(tableName))); writer.write("\n\n"); } if (client.hasIndexes(tableName)) { List<CatalogProtos.IndexDescProto> indexeProtos = client.getIndexes(tableName); for (CatalogProtos.IndexDescProto eachIndexProto : indexeProtos) { writer.write("\n\n"); writer.write(DDLBuilder.buildDDLForIndex(new IndexDesc(eachIndexProto))); } } writer.write("\n\n"); } catch (Exception e) { System.err.println("ERROR:" + tableName + "," + e.getMessage()); } } }

Target:
private static void dumpDatabase(TajoClient client, String databaseName, PrintWriter writer) throws SQLException, ServiceException { writer.write("\n"); writer.write("--\n"); writer.write(String.format("-- Database name: %s%n", CatalogUtil.denormalizeIdentifier(databaseName))); writer.write("--\n"); writer.write("\n"); writer.write(String.format("CREATE DATABASE IF NOT EXISTS %s;", CatalogUtil.denormalizeIdentifier(databaseName))); writer.write("\n\n"); List<String> tableNames = new ArrayList<>(client.getTableList(databaseName)); Collections.sort(tableNames); for (String tableName : tableNames) { try { String fqName = CatalogUtil.buildFQName(databaseName, tableName); TableDesc table = client.getTableDesc(fqName); if (table.getMeta().getDataFormat().equalsIgnoreCase("SYSTEM")) { continue; } if (table.isExternal()) { writer.write(DDLBuilder.buildDDLForExternalTable(table)); } else { writer.write(DDLBuilder.buildDDLForBaseTable(table)); } if (table.hasPartition()) { writer.write("\n\n"); writer.write("--\n"); writer.write(String.format("-- Table Partitions: %s%n", tableName)); writer.write("--\n"); writer.write(String.format("ALTER TABLE %s REPAIR PARTITION;", CatalogUtil.denormalizeIdentifier(databaseName) + "." + CatalogUtil.denormalizeIdentifier(tableName))); writer.write("\n\n"); } if (client.hasIndexes(tableName)) { List<CatalogProtos.IndexDescProto> indexeProtos = client.getIndexes(tableName); for (CatalogProtos.IndexDescProto eachIndexProto : indexeProtos) { writer.write("\n\n"); writer.write(DDLBuilder.buildDDLForIndex(new IndexDesc(eachIndexProto))); } } writer.write("\n\n"); } catch (Exception e) { System.err.println("ERROR:" + tableName + "," + e.getMessage()); } } }