Skip to content

Commit 777fe78

Browse files
committed
apacheGH-1090 Preserve Flight info statement API
1 parent e59a563 commit 777fe78

4 files changed

Lines changed: 56 additions & 1 deletion

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.arrow.driver.jdbc;
18+
19+
import java.sql.SQLException;
20+
import java.sql.Statement;
21+
import org.apache.arrow.flight.FlightInfo;
22+
23+
/** A {@link Statement} that deals with {@link FlightInfo}. */
24+
public interface ArrowFlightInfoStatement extends Statement {
25+
26+
@Override
27+
ArrowFlightConnection getConnection() throws SQLException;
28+
29+
/**
30+
* Executes the query this {@link Statement} is holding.
31+
*
32+
* @return the {@link FlightInfo} for the results.
33+
* @throws SQLException on error.
34+
*/
35+
FlightInfo executeFlightInfoQuery() throws SQLException;
36+
}

‎flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/ArrowFlightMetaStatement.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@
2727
import org.apache.calcite.avatica.remote.TypedValue;
2828

2929
/** Statement capabilities used by {@link ArrowFlightMetaImpl}. */
30-
interface ArrowFlightMetaStatement extends Statement {
30+
interface ArrowFlightMetaStatement extends ArrowFlightInfoStatement {
3131

3232
@Override
3333
ArrowFlightConnection getConnection() throws SQLException;
3434

35+
@Override
3536
FlightInfo executeFlightInfoQuery() throws SQLException;
3637

3738
/**

‎flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/ArrowFlightPreparedStatementTest.java‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,17 @@ public void before() {
8181
PRODUCER.clearActionTypeCounter();
8282
}
8383

84+
@Test
85+
public void testPreparedStatementKeepsFlightInfoStatementApi() throws SQLException {
86+
try (final PreparedStatement preparedStatement =
87+
connection.prepareStatement(CoreMockedSqlProducers.LEGACY_REGULAR_SQL_CMD)) {
88+
final ArrowFlightInfoStatement flightInfoStatement =
89+
(ArrowFlightInfoStatement) preparedStatement;
90+
91+
assertSame(preparedStatement, flightInfoStatement);
92+
}
93+
}
94+
8495
@Test
8596
public void testSimpleQueryNoParameterBinding() throws SQLException {
8697
final String query = CoreMockedSqlProducers.LEGACY_REGULAR_SQL_CMD;

‎flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/ArrowFlightStatementExecuteTest.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,13 @@ public static void tearDownAfterClass() throws Exception {
145145
AutoCloseables.close(PRODUCER);
146146
}
147147

148+
@Test
149+
public void testStatementKeepsFlightInfoStatementApi() {
150+
final ArrowFlightInfoStatement flightInfoStatement = (ArrowFlightInfoStatement) statement;
151+
152+
assertSame(statement, flightInfoStatement);
153+
}
154+
148155
@Test
149156
public void testExecuteShouldRunSelectQuery() throws SQLException {
150157
assertThat(statement.execute(SAMPLE_QUERY_CMD), is(true)); // Means this is a SELECT query.

0 commit comments

Comments
 (0)