Skip to content

Commit

Permalink
Relax assertion in JdbcRecordSetProvider
Browse files Browse the repository at this point in the history
We do not care about outputs order so assertion should not validate
that. The only thing we want to check is that we can cover the requested
set of columns with projection recorded in table handle.
  • Loading branch information
losipiuk committed Apr 27, 2021
1 parent a2ea77b commit d95fcd9
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package io.trino.plugin.jdbc;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import io.trino.spi.connector.ColumnHandle;
import io.trino.spi.connector.ConnectorRecordSetProvider;
import io.trino.spi.connector.ConnectorSession;
Expand Down Expand Up @@ -49,12 +50,12 @@ public RecordSet getRecordSet(ConnectorTransactionHandle transaction, ConnectorS
JdbcSplit jdbcSplit = (JdbcSplit) split;
JdbcTableHandle jdbcTable = (JdbcTableHandle) table;

// In the current API, the columns (and order) needed by the engine are provided via an argument to this method. Make sure that
// any columns that were recorded in the table handle match the requested set.
// In the current API, the columns (and order) needed by the engine are provided via an argument to this method. Make sure we can
// satisfy the requirements using columns which were recorded in the table handle.
// If no columns are recorded, it means that applyProjection never got called (e.g., in the case all columns are being used) and all
// table columns should be returned. TODO: this is something that should be addressed once the getRecordSet API is revamped
jdbcTable.getColumns()
.ifPresent(tableColumns -> verify(columns.equals(tableColumns)));
.ifPresent(tableColumns -> verify(ImmutableSet.copyOf(tableColumns).containsAll(columns)));

ImmutableList.Builder<JdbcColumnHandle> handles = ImmutableList.builder();
for (ColumnHandle handle : columns) {
Expand Down

0 comments on commit d95fcd9

Please sign in to comment.