in src/main/java/software/aws/glue/tableversions/utils/GlueUtil.java [76:116]
public List<Table> getTables(AWSGlue glue, List<Database> databaseList, String homeCatalogId) {
List<Table> masterTableList = new ArrayList<Table>();
// Iterate through all the databases
for (Database db : databaseList) {
String databaseName = db.getName();
// Get tables
GetTablesRequest getTablesRequest = new GetTablesRequest();
getTablesRequest.setDatabaseName(databaseName);
GetTablesResult getTablesResult = glue.getTables(getTablesRequest);
List<Table> tableList = getTablesResult.getTableList();
for (Table table : tableList) {
if (!Optional.ofNullable(table.getTargetTable()).isPresent()) {
masterTableList.add(table);
} else {
System.out.printf("Table '%s' under database '%s' seems to have resource linked from AWS Account Id: '%s'. So, it will be skipped. \n",
table.getName(), table.getDatabaseName(), table.getTargetTable().getCatalogId());
}
}
String tableResultNextToken = getTablesResult.getNextToken();
if (Optional.ofNullable(tableResultNextToken).isPresent()) {
do {
getTablesRequest = new GetTablesRequest();
getTablesRequest.setDatabaseName(databaseName);
getTablesRequest.setNextToken(tableResultNextToken);
getTablesResult = glue.getTables(getTablesRequest);
tableList = getTablesResult.getTableList();
for (Table table : tableList) {
if (!Optional.ofNullable(table.getTargetTable()).isPresent()) {
masterTableList.add(table);
} else {
System.out.printf("Table '%s' under database '%s' seems to have resource linked from AWS Account Id: '%s'. So, it will be skipped. \n",
table.getName(), table.getDatabaseName(), table.getTargetTable().getCatalogId());
}
}
tableResultNextToken = getTablesResult.getNextToken();
} while (Optional.ofNullable(tableResultNextToken).isPresent());
}
}
return masterTableList;
}