Search in sources :

Example 1 with AtopColumn

use of com.facebook.presto.atop.AtopTable.AtopColumn in project presto by prestodb.

the class AtopMetadata method getColumnHandles.

@Override
public Map<String, ColumnHandle> getColumnHandles(ConnectorSession session, ConnectorTableHandle tableHandle) {
    AtopTableHandle atopTableHandle = (AtopTableHandle) tableHandle;
    ImmutableMap.Builder<String, ColumnHandle> columnHandles = ImmutableMap.builder();
    for (AtopColumn column : atopTableHandle.getTable().getColumns()) {
        columnHandles.put(column.getName(), new AtopColumnHandle(column.getName()));
    }
    return columnHandles.build();
}
Also used : ColumnHandle(com.facebook.presto.spi.ColumnHandle) AtopColumn(com.facebook.presto.atop.AtopTable.AtopColumn) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 2 with AtopColumn

use of com.facebook.presto.atop.AtopTable.AtopColumn in project presto by prestodb.

the class AtopMetadata method getTableMetadata.

@Override
public ConnectorTableMetadata getTableMetadata(ConnectorSession session, ConnectorTableHandle tableHandle) {
    AtopTableHandle atopTableHandle = (AtopTableHandle) tableHandle;
    ImmutableList.Builder<ColumnMetadata> columns = ImmutableList.builder();
    for (AtopColumn column : atopTableHandle.getTable().getColumns()) {
        columns.add(new ColumnMetadata(column.getName(), typeManager.getType(column.getType())));
    }
    SchemaTableName schemaTableName = new SchemaTableName(atopTableHandle.getSchema(), atopTableHandle.getTable().getName());
    return new ConnectorTableMetadata(schemaTableName, columns.build());
}
Also used : ColumnMetadata(com.facebook.presto.spi.ColumnMetadata) AtopColumn(com.facebook.presto.atop.AtopTable.AtopColumn) ImmutableList(com.google.common.collect.ImmutableList) SchemaTableName(com.facebook.presto.spi.SchemaTableName) ConnectorTableMetadata(com.facebook.presto.spi.ConnectorTableMetadata)

Example 3 with AtopColumn

use of com.facebook.presto.atop.AtopTable.AtopColumn in project presto by prestodb.

the class AtopPageSourceProvider method createPageSource.

@Override
public ConnectorPageSource createPageSource(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorSplit split, List<ColumnHandle> columns) {
    AtopSplit atopSplit = (AtopSplit) split;
    ImmutableList.Builder<Type> types = ImmutableList.builder();
    ImmutableList.Builder<AtopColumn> atopColumns = ImmutableList.builder();
    for (ColumnHandle column : columns) {
        AtopColumnHandle atopColumnHandle = (AtopColumnHandle) column;
        AtopColumn atopColumn = atopSplit.getTable().getColumn(atopColumnHandle.getName());
        atopColumns.add(atopColumn);
        types.add(typeManager.getType(atopColumn.getType()));
    }
    ZonedDateTime date = atopSplit.getDate();
    checkArgument(date.equals(date.withHour(0).withMinute(0).withSecond(0).withNano(0)), "Expected date to be at beginning of day");
    return new AtopPageSource(readerPermits, atopFactory, session, utf8Slice(atopSplit.getHost().getHostText()), atopSplit.getTable(), date, atopColumns.build(), types.build());
}
Also used : ColumnHandle(com.facebook.presto.spi.ColumnHandle) Type(com.facebook.presto.spi.type.Type) AtopColumn(com.facebook.presto.atop.AtopTable.AtopColumn) ZonedDateTime(java.time.ZonedDateTime) ImmutableList(com.google.common.collect.ImmutableList)

Aggregations

AtopColumn (com.facebook.presto.atop.AtopTable.AtopColumn)3 ColumnHandle (com.facebook.presto.spi.ColumnHandle)2 ImmutableList (com.google.common.collect.ImmutableList)2 ColumnMetadata (com.facebook.presto.spi.ColumnMetadata)1 ConnectorTableMetadata (com.facebook.presto.spi.ConnectorTableMetadata)1 SchemaTableName (com.facebook.presto.spi.SchemaTableName)1 Type (com.facebook.presto.spi.type.Type)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ZonedDateTime (java.time.ZonedDateTime)1