use of org.apache.drill.metastore.rdbms.transform.MetadataMapper in project drill by apache.
the class RdbmsRead method internalExecute.
@Override
protected List<T> internalExecute() {
Set<MetadataMapper<T, ? extends Record>> mappers = context.transformer().toMappers(metadataTypes);
if (mappers.isEmpty()) {
return Collections.emptyList();
}
List<T> units = new ArrayList<>();
try (DSLContext executor = context.executorProvider().executor()) {
for (MetadataMapper<T, ? extends Record> mapper : mappers) {
Condition condition = mapper.toCondition(filter);
logger.debug("Query data from RDBMS Metastore table {} using condition: {}", mapper.table(), condition);
List<Field<?>> fields = columns.isEmpty() ? Arrays.asList(mapper.table().fields()) : mapper.toFields(columns);
try {
if (fields.isEmpty()) {
units.addAll(countRecords(executor, mapper, condition));
} else {
units.addAll(queryRecords(executor, mapper, fields, condition));
}
} catch (DataAccessException e) {
throw new RdbmsMetastoreException("Error when reading data from Metastore: " + e.getMessage(), e);
}
}
return units;
}
}
Aggregations