use of io.prestosql.client.Column in project hetu-core by openlookeng.
the class ColumnService method queryColumns.
private List<Column> queryColumns(String fqnTableName, String user) {
String statement = format("SHOW COLUMNS FROM %s", fqnTableName);
QueryRunner queryRunner = queryRunnerFactory.create(QueryEditorUIModule.UI_QUERY_SOURCE, user);
QueryClient queryClient = new QueryClient(queryRunner, Duration.standardSeconds(60), statement);
final ImmutableList.Builder<Column> cache = ImmutableList.builder();
try {
queryClient.executeWith(new Function<StatementClient, Void>() {
@Nullable
@Override
public Void apply(StatementClient client) {
QueryData results = client.currentData();
if (results.getData() != null) {
for (List<Object> row : results.getData()) {
TypeSignature typeSignature = TypeSignature.parseTypeSignature((String) row.get(1));
Column column = new Column((String) row.get(0), (String) row.get(1), Query.toClientTypeSignature(typeSignature));
cache.add(column);
}
}
return null;
}
});
} catch (QueryClient.QueryTimeOutException e) {
log.error("Caught timeout loading columns", e);
}
return cache.build();
}
Aggregations