diff --git a/java/flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/ArrowDatabaseMetadata.java b/java/flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/ArrowDatabaseMetadata.java index d68b8070e2bb7..da8e32bbb994d 100644 --- a/java/flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/ArrowDatabaseMetadata.java +++ b/java/flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/ArrowDatabaseMetadata.java @@ -754,7 +754,11 @@ private T getSqlInfoAndCacheIfCacheIsEmpty(final SqlInfo sqlInfoCommand, } private String convertListSqlInfoToString(final List sqlInfoList) { - return sqlInfoList.stream().map(Object::toString).collect(Collectors.joining(", ")); + if (sqlInfoList == null) { + return ""; + } else { + return sqlInfoList.stream().map(Object::toString).collect(Collectors.joining(", ")); + } } private boolean getSqlInfoEnumOptionAndCacheIfCacheIsEmpty( diff --git a/java/flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/ArrowDatabaseMetadataTest.java b/java/flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/ArrowDatabaseMetadataTest.java index 0d930f4c44e1f..51334c77486bf 100644 --- a/java/flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/ArrowDatabaseMetadataTest.java +++ b/java/flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/ArrowDatabaseMetadataTest.java @@ -95,9 +95,14 @@ public class ArrowDatabaseMetadataTest { public static final boolean EXPECTED_MAX_ROW_SIZE_INCLUDES_BLOBS = false; private static final MockFlightSqlProducer FLIGHT_SQL_PRODUCER = new MockFlightSqlProducer(); + private static final MockFlightSqlProducer FLIGHT_SQL_PRODUCER_EMPTY_SQLINFO = + new MockFlightSqlProducer(); @ClassRule public static final FlightServerTestRule FLIGHT_SERVER_TEST_RULE = FlightServerTestRule .createStandardTestRule(FLIGHT_SQL_PRODUCER); + @ClassRule + public static final FlightServerTestRule FLIGHT_SERVER_EMPTY_SQLINFO_TEST_RULE = + FlightServerTestRule.createStandardTestRule(FLIGHT_SQL_PRODUCER_EMPTY_SQLINFO); private static final int ROW_COUNT = 10; private static final List> EXPECTED_GET_CATALOGS_RESULTS = range(0, ROW_COUNT) @@ -604,7 +609,7 @@ public static void setUpBeforeClass() throws SQLException { @AfterClass public static void tearDown() throws Exception { - AutoCloseables.close(connection, FLIGHT_SQL_PRODUCER); + AutoCloseables.close(connection, FLIGHT_SQL_PRODUCER, FLIGHT_SQL_PRODUCER_EMPTY_SQLINFO); } @@ -1420,4 +1425,16 @@ public void testSqlToRegexLike() { Assert.assertEquals("\\*", ArrowDatabaseMetadata.sqlToRegexLike("*")); Assert.assertEquals("T\\*E.S.*T", ArrowDatabaseMetadata.sqlToRegexLike("T*E_S%T")); } + + @Test + public void testEmptySqlInfo() throws Exception { + try (final Connection testConnection = FLIGHT_SERVER_EMPTY_SQLINFO_TEST_RULE.getConnection(false)) { + final DatabaseMetaData metaData = testConnection.getMetaData(); + collector.checkThat(metaData.getSQLKeywords(), is("")); + collector.checkThat(metaData.getNumericFunctions(), is("")); + collector.checkThat(metaData.getStringFunctions(), is("")); + collector.checkThat(metaData.getSystemFunctions(), is("")); + collector.checkThat(metaData.getTimeDateFunctions(), is("")); + } + } }