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);
}
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());
}
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);
}
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();
}
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);
}
Aggregations