Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public FlightInfo executeFlightInfoQuery() throws SQLException {
}

final Schema resultSetSchema = preparedStatement.getDataSetSchema();
signature.columns.clear();
signature.columns.addAll(
ConvertUtils.convertArrowFieldsToColumnMetaDataList(resultSetSchema.getFields()));
setSignature(signature);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,23 @@ public void testShouldIsSearchable() throws SQLException {
public void testShouldGetColumnTypesFromOutOfBoundIndex() {
assertThrows(IndexOutOfBoundsException.class, () -> metadata.getColumnType(4));
}

/**
* Regression test for <a href="https://github.com/apache/arrow-java/issues/44">issue #44</a>:
* {@code ArrowFlightStatement#executeFlightInfoQuery} appends schema columns to the reused {@code
* Meta.Signature} without clearing the existing list. When the result has at least one endpoint,
* the {@code FlightStream} consumption path overwrites {@code signature.columns} from the actual
* stream schema and hides the duplication. With an empty endpoint list — the scenario reported
* against both Rust- and Denodo-based Flight SQL servers — that overwrite never runs and {@code
* ResultSetMetaData#getColumnCount()} reports double the schema width.
*/
@Test
public void testShouldNotDuplicateColumnsWhenFlightInfoHasNoEndpoints() throws SQLException {
try (Connection conn = FLIGHT_SERVER_TEST_EXTENSION.getConnection(false);
Statement st = conn.createStatement();
ResultSet rs =
st.executeQuery(CoreMockedSqlProducers.LEGACY_REGULAR_NO_ENDPOINTS_SQL_CMD)) {
assertThat(rs.getMetaData().getColumnCount(), equalTo(1));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public final class CoreMockedSqlProducers {
public static final String LEGACY_METADATA_SQL_CMD = "SELECT * FROM METADATA";
public static final String LEGACY_CANCELLATION_SQL_CMD = "SELECT * FROM TAKES_FOREVER";
public static final String LEGACY_REGULAR_WITH_EMPTY_SQL_CMD = "SELECT * FROM TEST_EMPTIES";
public static final String LEGACY_REGULAR_NO_ENDPOINTS_SQL_CMD =
"SELECT * FROM TEST_NO_ENDPOINTS";

public static final String UUID_SQL_CMD = "SELECT * FROM UUID_TABLE";
public static final String UUID_PREPARED_SELECT_SQL_CMD =
Expand Down Expand Up @@ -100,12 +102,22 @@ public static MockFlightSqlProducer getLegacyProducer() {
addLegacyMetadataSqlCmdSupport(producer);
addLegacyCancellationSqlCmdSupport(producer);
addQueryWithEmbeddedEmptyRoot(producer);
addQueryWithNoEndpoints(producer);
addUuidSqlCmdSupport(producer);
addUuidPreparedSelectSqlCmdSupport(producer);
addUuidPreparedUpdateSqlCmdSupport(producer);
return producer;
}

private static void addQueryWithNoEndpoints(final MockFlightSqlProducer producer) {
final Schema querySchema =
new Schema(
ImmutableList.of(
new Field("ID", new FieldType(true, new ArrowType.Int(64, true), null), null)));
producer.addSelectQuery(
LEGACY_REGULAR_NO_ENDPOINTS_SQL_CMD, querySchema, Collections.emptyList());
}

/**
* Gets a {@link MockFlightSqlProducer} configured with UUID test data.
*
Expand Down
Loading