if (updateCacheImmediately || connection.getAutoCommit()) {
MetaDataMutationResult result = client.updateCache(schemaName, tableName);
timeStamp = result.getMutationTime();
theTable = result.getTable();
if (theTable == null) {
throw new TableNotFoundException(schemaName, tableName, timeStamp);
}
} else {
try {
theTable = connection.getMetaDataCache().getTable(new PTableKey(tenantId, fullTableName));
} catch (TableNotFoundException e1) {
if (tenantId != null) { // Check with null tenantId next
try {
theTable = connection.getMetaDataCache().getTable(new PTableKey(null, fullTableName));
} catch (TableNotFoundException e2) {
}
}
}
// We always attempt to update the cache in the event of a TableNotFoundException
if (theTable == null) {
MetaDataMutationResult result = client.updateCache(schemaName, tableName);
if (result.wasUpdated()) {
timeStamp = result.getMutationTime();
theTable = result.getTable();
}
}
if (theTable == null) {
throw new TableNotFoundException(schemaName, tableName, timeStamp);
}
}
// Add any dynamic columns to the table declaration
List<ColumnDef> dynamicColumns = tableNode.getDynamicColumns();
theTable = addDynamicColumns(dynamicColumns, theTable);