use of com.facebook.presto.client.ClientTypeSignature in project airpal by airbnb.
the class ColumnCache method queryColumns.
private List<HiveColumn> queryColumns(String query) {
final ImmutableList.Builder<HiveColumn> cache = ImmutableList.builder();
QueryRunner queryRunner = queryRunnerFactory.create();
QueryClient queryClient = new QueryClient(queryRunner, io.dropwizard.util.Duration.seconds(60), query);
try {
queryClient.executeWith(new Function<StatementClient, Void>() {
@Nullable
@Override
public Void apply(StatementClient client) {
QueryResults results = client.current();
if (results.getData() != null) {
for (List<Object> row : results.getData()) {
Column column = new Column((String) row.get(0), (String) row.get(1), new ClientTypeSignature(TypeSignature.parseTypeSignature((String) row.get(1))));
boolean isNullable = (Boolean) row.get(2);
boolean isPartition = (Boolean) row.get(3);
cache.add(HiveColumn.fromColumn(column, isNullable, isPartition));
}
}
return null;
}
});
} catch (QueryClient.QueryTimeOutException e) {
log.error("Caught timeout loading columns", e);
}
return cache.build();
}
Aggregations