@Override
public RecordSet getRecordSet(ConnectorSplit split, List<? extends ConnectorColumnHandle> columns)
{
int sampleWeightField = -1;
for (int i = 0; i < columns.size(); i++) {
ConnectorColumnHandle column = columns.get(i);
if (column instanceof TpchColumnHandle && ((TpchColumnHandle) column).getColumnName().equals(SampledTpchMetadata.SAMPLE_WEIGHT_COLUMN_NAME)) {
sampleWeightField = i;
break;
}
}
List<? extends ConnectorColumnHandle> delegatedColumns = new ArrayList<>(columns);
if (sampleWeightField > -1) {
delegatedColumns.remove(sampleWeightField);
RecordSet recordSet;
if (delegatedColumns.isEmpty()) {
// Pick a random column, so that we can figure out how many rows there are
TpchSplit tpchSplit = (TpchSplit) split;
ConnectorColumnHandle column = Iterables.getFirst(metadata.getColumnHandles(tpchSplit.getTableHandle()).values(), null);
checkNotNull(column, "Could not find any columns");
recordSet = new EmptyRecordSet(super.getRecordSet(split, ImmutableList.of(column)));
}
else {
recordSet = super.getRecordSet(split, delegatedColumns);