use of io.prestosql.client.Column in project hetu-core by openlookeng.
the class Query method setQueryOutputInfo.
private synchronized void setQueryOutputInfo(QueryExecution.QueryOutputInfo outputInfo) {
// if first callback, set column names
if (columns == null) {
List<String> columnNames = outputInfo.getColumnNames();
List<Type> columnTypes = outputInfo.getColumnTypes();
checkArgument(columnNames.size() == columnTypes.size(), "Column names and types size mismatch");
ImmutableList.Builder<Column> list = ImmutableList.builder();
for (int i = 0; i < columnNames.size(); i++) {
list.add(createColumn(columnNames.get(i), columnTypes.get(i)));
}
columns = list.build();
types = outputInfo.getColumnTypes();
}
for (TaskLocation outputLocation : outputInfo.getBufferLocations()) {
exchangeClient.addLocation(outputLocation);
}
if (outputInfo.isNoMoreBufferLocations()) {
exchangeClient.noMoreLocations();
}
}
use of io.prestosql.client.Column in project hetu-core by openlookeng.
the class PrestoResultSet method getColumnInfo.
private static List<ColumnInfo> getColumnInfo(List<Column> columns) {
ImmutableList.Builder<ColumnInfo> list = ImmutableList.builder();
for (Column column : columns) {
ColumnInfo.Builder builder = new ColumnInfo.Builder().setCatalogName(// TODO
"").setSchemaName(// TODO
"").setTableName(// TODO
"").setColumnLabel(column.getName()).setColumnName(// TODO
column.getName()).setColumnTypeSignature(column.getTypeSignature()).setNullable(Nullable.UNKNOWN).setCurrency(false);
setTypeInfo(builder, column.getTypeSignature());
list.add(builder.build());
}
return list.build();
}
use of io.prestosql.client.Column in project hetu-core by openlookeng.
the class PrestoResultSet method getColumns.
private static List<Column> getColumns(StatementClient client, Consumer<QueryStats> progressCallback) throws SQLException {
while (client.isRunning()) {
QueryStatusInfo tmpResults = client.currentStatusInfo();
progressCallback.accept(QueryStats.create(tmpResults.getId(), tmpResults.getStats()));
List<Column> columns = tmpResults.getColumns();
if (columns != null) {
return columns;
}
client.advance();
}
verify(client.isFinished());
QueryStatusInfo tmpResults = client.finalStatusInfo();
if (tmpResults.getError() == null) {
throw new SQLException(format("Query has no columns (#%s)", tmpResults.getId()));
}
throw resultsException(tmpResults);
}
use of io.prestosql.client.Column in project hetu-core by openlookeng.
the class MetadataResource method getTableColumns.
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("columns/{catalog}/{schema}/{table}")
public Response getTableColumns(@PathParam("catalog") String catalogName, @PathParam("schema") String schemaName, @PathParam("table") String tableName, @Context HttpServletRequest servletRequest) throws ExecutionException {
String user = AccessControlUtil.getUser(accessControl, new HttpRequestSessionContext(servletRequest, groupProvider));
List<Column> columnList = columnService.getColumns(catalogName, schemaName, tableName, user);
return Response.ok(columnList).build();
}
use of io.prestosql.client.Column in project hetu-core by openlookeng.
the class TestAlignedTablePrinter method testAlignedPrintingHex.
@Test
public void testAlignedPrintingHex() throws Exception {
List<Column> columns = ImmutableList.<Column>builder().add(column("first", VARCHAR)).add(column("binary", VARBINARY)).add(column("last", VARCHAR)).build();
StringWriter writer = new StringWriter();
OutputPrinter printer = new AlignedTablePrinter(columns, writer);
printer.printRows(rows(row("hello", bytes("hello"), "world"), row("a", bytes("some long text that is more than 16 bytes"), "b"), row("cat", bytes(""), "dog")), true);
printer.finish();
String expected = "" + " first | binary | last \n" + "-------+-------------------------------------------------+-------\n" + " hello | 68 65 6c 6c 6f | world \n" + " a | 73 6f 6d 65 20 6c 6f 6e 67 20 74 65 78 74 20 74+| b \n" + " | 68 61 74 20 69 73 20 6d 6f 72 65 20 74 68 61 6e+| \n" + " | 20 31 36 20 62 79 74 65 73 | \n" + " cat | | dog \n" + "(3 rows)\n";
assertEquals(writer.getBuffer().toString(), expected);
}
Aggregations