Search in sources :

Example 1 with Table

use of com.teradata.tpcds.Table in project presto by prestodb.

the class TpcdsMetadata method getTableMetadata.

@Override
public ConnectorTableMetadata getTableMetadata(ConnectorSession session, ConnectorTableHandle tableHandle) {
    TpcdsTableHandle tpcdsTableHandle = (TpcdsTableHandle) tableHandle;
    Table table = Table.getTable(tpcdsTableHandle.getTableName());
    String schemaName = scaleFactorSchemaName(tpcdsTableHandle.getScaleFactor());
    return getTableMetadata(schemaName, table);
}
Also used : Table(com.teradata.tpcds.Table)

Example 2 with Table

use of com.teradata.tpcds.Table in project presto by prestodb.

the class TpcdsRecordSetProvider method getRecordSet.

@Override
public RecordSet getRecordSet(ConnectorTransactionHandle transaction, ConnectorSession session, ConnectorSplit split, List<? extends ColumnHandle> columns) {
    TpcdsSplit tpcdsSplit = (TpcdsSplit) split;
    String tableName = tpcdsSplit.getTableHandle().getTableName();
    Table table = getTable(tableName);
    return getRecordSet(table, columns, tpcdsSplit.getTableHandle().getScaleFactor(), tpcdsSplit.getPartNumber(), tpcdsSplit.getTotalParts(), tpcdsSplit.isNoSexism());
}
Also used : Table.getTable(com.teradata.tpcds.Table.getTable) Table(com.teradata.tpcds.Table)

Example 3 with Table

use of com.teradata.tpcds.Table in project presto by prestodb.

the class TpcdsMetadata method getTableStatistics.

@Override
public TableStatistics getTableStatistics(ConnectorSession session, ConnectorTableHandle tableHandle, Optional<ConnectorTableLayoutHandle> tableLayoutHandle, List<ColumnHandle> columnHandles, Constraint<ColumnHandle> constraint) {
    TpcdsTableHandle tpcdsTableHandle = (TpcdsTableHandle) tableHandle;
    Table table = Table.getTable(tpcdsTableHandle.getTableName());
    String schemaName = scaleFactorSchemaName(tpcdsTableHandle.getScaleFactor());
    return tpcdsTableStatisticsFactory.create(schemaName, table, columnHandles);
}
Also used : Table(com.teradata.tpcds.Table)

Example 4 with Table

use of com.teradata.tpcds.Table in project presto by prestodb.

the class TpcdsMetadata method listTableColumns.

@Override
public Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorSession session, SchemaTablePrefix prefix) {
    ImmutableMap.Builder<SchemaTableName, List<ColumnMetadata>> tableColumns = ImmutableMap.builder();
    for (String schemaName : getSchemaNames(session, Optional.ofNullable(prefix.getSchemaName()))) {
        for (Table tpcdsTable : Table.getBaseTables()) {
            if (prefix.getTableName() == null || tpcdsTable.getName().equals(prefix.getTableName())) {
                ConnectorTableMetadata tableMetadata = getTableMetadata(schemaName, tpcdsTable);
                tableColumns.put(new SchemaTableName(schemaName, tpcdsTable.getName()), tableMetadata.getColumns());
            }
        }
    }
    return tableColumns.build();
}
Also used : Table(com.teradata.tpcds.Table) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) SchemaTableName(com.facebook.presto.spi.SchemaTableName) ImmutableMap(com.google.common.collect.ImmutableMap) ConnectorTableMetadata(com.facebook.presto.spi.ConnectorTableMetadata)

Example 5 with Table

use of com.teradata.tpcds.Table in project presto by prestodb.

the class TableStatisticsRecorder method recordStatistics.

public TableStatisticsData recordStatistics(Table table, double scaleFactor) {
    Session session = Session.getDefaultSession().withScale(scaleFactor).withParallelism(1).withNoSexism(false);
    List<Column> columns = ImmutableList.copyOf(table.getColumns());
    RecordCursor recordCursor = new TpcdsRecordSet(Results.constructResults(table, session), columns).cursor();
    List<ColumnStatisticsRecorder> statisticsRecorders = createStatisticsRecorders(columns);
    long rowCount = 0;
    while (recordCursor.advanceNextPosition()) {
        rowCount++;
        for (int columnId = 0; columnId < columns.size(); columnId++) {
            Comparable<?> value = getPrestoValue(recordCursor, columns, columnId);
            statisticsRecorders.get(columnId).record(value);
        }
    }
    Map<String, ColumnStatisticsData> columnSampleStatistics = IntStream.range(0, columns.size()).boxed().collect(toImmutableMap(i -> columns.get(i).getName(), i -> statisticsRecorders.get(i).getRecording()));
    return new TableStatisticsData(rowCount, columnSampleStatistics);
}
Also used : IntStream(java.util.stream.IntStream) Session(com.teradata.tpcds.Session) TpcdsRecordSet(com.facebook.presto.tpcds.TpcdsRecordSet) Results(com.teradata.tpcds.Results) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) String.format(java.lang.String.format) RecordCursor(com.facebook.presto.spi.RecordCursor) List(java.util.List) ImmutableMap.toImmutableMap(com.google.common.collect.ImmutableMap.toImmutableMap) ImmutableList(com.google.common.collect.ImmutableList) Column(com.teradata.tpcds.column.Column) Map(java.util.Map) ColumnType(com.teradata.tpcds.column.ColumnType) Table(com.teradata.tpcds.Table) RecordCursor(com.facebook.presto.spi.RecordCursor) TpcdsRecordSet(com.facebook.presto.tpcds.TpcdsRecordSet) Column(com.teradata.tpcds.column.Column) Session(com.teradata.tpcds.Session)

Aggregations

Table (com.teradata.tpcds.Table)5 ImmutableList (com.google.common.collect.ImmutableList)2 List (java.util.List)2 ConnectorTableMetadata (com.facebook.presto.spi.ConnectorTableMetadata)1 RecordCursor (com.facebook.presto.spi.RecordCursor)1 SchemaTableName (com.facebook.presto.spi.SchemaTableName)1 TpcdsRecordSet (com.facebook.presto.tpcds.TpcdsRecordSet)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableMap.toImmutableMap (com.google.common.collect.ImmutableMap.toImmutableMap)1 Results (com.teradata.tpcds.Results)1 Session (com.teradata.tpcds.Session)1 Table.getTable (com.teradata.tpcds.Table.getTable)1 Column (com.teradata.tpcds.column.Column)1 ColumnType (com.teradata.tpcds.column.ColumnType)1 String.format (java.lang.String.format)1 Map (java.util.Map)1 IntStream (java.util.stream.IntStream)1