diff --git a/java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/JdbcToArrow.java b/java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/JdbcToArrow.java
index c65523d837f..daee64d9308 100644
--- a/java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/JdbcToArrow.java
+++ b/java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/JdbcToArrow.java
@@ -18,17 +18,11 @@
package org.apache.arrow.adapter.jdbc;
import java.io.IOException;
-import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Calendar;
import org.apache.arrow.memory.BufferAllocator;
-import org.apache.arrow.memory.RootAllocator;
import org.apache.arrow.util.Preconditions;
-import org.apache.arrow.vector.VectorSchemaRoot;
-import org.apache.arrow.vector.util.ValueVectorUtility;
/**
* Utility class to convert JDBC objects to columnar Arrow format objects.
@@ -64,170 +58,6 @@
*/
public class JdbcToArrow {
- /**
- * For the given SQL query, execute and fetch the data from Relational DB and convert it to Arrow objects.
- * This method uses the default Calendar instance with default TimeZone and Locale as returned by the JVM.
- * If you wish to use specific TimeZone or Locale for any Date, Time and Timestamp datasets, you may want use
- * overloaded API that taken Calendar object instance.
- *
- * @param connection Database connection to be used. This method will not close the passed connection object. Since
- * the caller has passed the connection object it's the responsibility of the caller to close or
- * return the connection to the pool.
- * @param query The DB Query to fetch the data.
- * @param allocator Memory allocator
- * @return Arrow Data Objects {@link VectorSchemaRoot}
- * @throws SQLException Propagate any SQL Exceptions to the caller after closing any resources opened such as
- * ResultSet and Statement objects.
- */
- @Deprecated
- public static VectorSchemaRoot sqlToArrow(Connection connection, String query, BufferAllocator allocator)
- throws SQLException, IOException {
- Preconditions.checkNotNull(allocator, "Memory allocator object can not be null");
-
- JdbcToArrowConfig config =
- new JdbcToArrowConfig(allocator, JdbcToArrowUtils.getUtcCalendar());
- return sqlToArrow(connection, query, config);
- }
-
- /**
- * For the given SQL query, execute and fetch the data from Relational DB and convert it to Arrow objects.
- *
- * @param connection Database connection to be used. This method will not close the passed connection object. Since
- * the caller has passed the connection object it's the responsibility of the caller to close or
- * return the connection to the pool.
- * @param query The DB Query to fetch the data.
- * @param allocator Memory allocator
- * @param calendar Calendar object to use to handle Date, Time and Timestamp datasets.
- * @return Arrow Data Objects {@link VectorSchemaRoot}
- * @throws SQLException Propagate any SQL Exceptions to the caller after closing any resources opened such as
- * ResultSet and Statement objects.
- */
- @Deprecated
- public static VectorSchemaRoot sqlToArrow(
- Connection connection,
- String query,
- BufferAllocator allocator,
- Calendar calendar) throws SQLException, IOException {
-
- Preconditions.checkNotNull(allocator, "Memory allocator object can not be null");
- Preconditions.checkNotNull(calendar, "Calendar object can not be null");
-
- return sqlToArrow(connection, query, new JdbcToArrowConfig(allocator, calendar));
- }
-
- /**
- * For the given SQL query, execute and fetch the data from Relational DB and convert it to Arrow objects.
- *
- * @param connection Database connection to be used. This method will not close the passed connection object.
- * Since the caller has passed the connection object it's the responsibility of the caller
- * to close or return the connection to the pool.
- * @param query The DB Query to fetch the data.
- * @param config Configuration
- * @return Arrow Data Objects {@link VectorSchemaRoot}
- * @throws SQLException Propagate any SQL Exceptions to the caller after closing any resources opened such as
- * ResultSet and Statement objects.
- */
- @Deprecated
- public static VectorSchemaRoot sqlToArrow(Connection connection, String query, JdbcToArrowConfig config)
- throws SQLException, IOException {
- Preconditions.checkNotNull(connection, "JDBC connection object can not be null");
- Preconditions.checkArgument(query != null && query.length() > 0, "SQL query can not be null or empty");
-
- try (Statement stmt = connection.createStatement()) {
- return sqlToArrow(stmt.executeQuery(query), config);
- }
- }
-
- /**
- * For the given JDBC {@link ResultSet}, fetch the data from Relational DB and convert it to Arrow objects. This
- * method uses the default RootAllocator and Calendar object.
- *
- * @param resultSet ResultSet to use to fetch the data from underlying database
- * @return Arrow Data Objects {@link VectorSchemaRoot}
- * @throws SQLException on error
- */
- @Deprecated
- public static VectorSchemaRoot sqlToArrow(ResultSet resultSet) throws SQLException, IOException {
- Preconditions.checkNotNull(resultSet, "JDBC ResultSet object can not be null");
-
- return sqlToArrow(resultSet, JdbcToArrowUtils.getUtcCalendar());
- }
-
- /**
- * For the given JDBC {@link ResultSet}, fetch the data from Relational DB and convert it to Arrow objects.
- *
- * @param resultSet ResultSet to use to fetch the data from underlying database
- * @param allocator Memory allocator
- * @return Arrow Data Objects {@link VectorSchemaRoot}
- * @throws SQLException on error
- */
- @Deprecated
- public static VectorSchemaRoot sqlToArrow(ResultSet resultSet, BufferAllocator allocator)
- throws SQLException, IOException {
- Preconditions.checkNotNull(allocator, "Memory Allocator object can not be null");
-
- JdbcToArrowConfig config =
- new JdbcToArrowConfig(allocator, JdbcToArrowUtils.getUtcCalendar());
- return sqlToArrow(resultSet, config);
- }
-
- /**
- * For the given JDBC {@link ResultSet}, fetch the data from Relational DB and convert it to Arrow objects.
- *
- * @param resultSet ResultSet to use to fetch the data from underlying database
- * @param calendar Calendar instance to use for Date, Time and Timestamp datasets, or null if none.
- * @return Arrow Data Objects {@link VectorSchemaRoot}
- * @throws SQLException on error
- */
- @Deprecated
- public static VectorSchemaRoot sqlToArrow(ResultSet resultSet, Calendar calendar) throws SQLException, IOException {
- Preconditions.checkNotNull(resultSet, "JDBC ResultSet object can not be null");
- return sqlToArrow(resultSet, new JdbcToArrowConfig(new RootAllocator(Integer.MAX_VALUE), calendar));
- }
-
- /**
- * For the given JDBC {@link ResultSet}, fetch the data from Relational DB and convert it to Arrow objects.
- *
- * @param resultSet ResultSet to use to fetch the data from underlying database
- * @param allocator Memory allocator to use.
- * @param calendar Calendar instance to use for Date, Time and Timestamp datasets, or null if none.
- * @return Arrow Data Objects {@link VectorSchemaRoot}
- * @throws SQLException on error
- */
- @Deprecated
- public static VectorSchemaRoot sqlToArrow(
- ResultSet resultSet,
- BufferAllocator allocator,
- Calendar calendar)
- throws SQLException, IOException {
- Preconditions.checkNotNull(allocator, "Memory Allocator object can not be null");
-
- return sqlToArrow(resultSet, new JdbcToArrowConfig(allocator, calendar));
- }
-
- /**
- * For the given JDBC {@link ResultSet}, fetch the data from Relational DB and convert it to Arrow objects.
- *
- * @param resultSet ResultSet to use to fetch the data from underlying database
- * @param config Configuration of the conversion from JDBC to Arrow.
- * @return Arrow Data Objects {@link VectorSchemaRoot}
- * @throws SQLException on error
- */
- @Deprecated
- public static VectorSchemaRoot sqlToArrow(ResultSet resultSet, JdbcToArrowConfig config)
- throws SQLException, IOException {
- Preconditions.checkNotNull(resultSet, "JDBC ResultSet object can not be null");
- Preconditions.checkNotNull(config, "The configuration cannot be null");
-
- VectorSchemaRoot root = VectorSchemaRoot.create(
- JdbcToArrowUtils.jdbcToArrowSchema(resultSet.getMetaData(), config), config.getAllocator());
- if (config.getTargetBatchSize() != JdbcToArrowConfig.NO_LIMIT_BATCH_SIZE) {
- ValueVectorUtility.preAllocate(root, config.getTargetBatchSize());
- }
- JdbcToArrowUtils.jdbcToArrowVectors(resultSet, root, config);
- return root;
- }
-
/*----------------------------------------------------------------*
| |
| Partial Convert API |
diff --git a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/AbstractJdbcToArrowTest.java b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/AbstractJdbcToArrowTest.java
index 616363ecf64..747e84e89e9 100644
--- a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/AbstractJdbcToArrowTest.java
+++ b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/AbstractJdbcToArrowTest.java
@@ -20,10 +20,16 @@
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
+import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
+import java.util.Calendar;
+import org.apache.arrow.memory.BufferAllocator;
+import org.apache.arrow.memory.RootAllocator;
+import org.apache.arrow.util.Preconditions;
import org.apache.arrow.vector.VectorSchemaRoot;
+import org.apache.arrow.vector.util.ValueVectorUtility;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -140,4 +146,160 @@ public static Object[][] prepareTestData(String[] testFiles, @SuppressWarnings("
*/
public abstract void testDataSets(VectorSchemaRoot root);
+ /**
+ * For the given SQL query, execute and fetch the data from Relational DB and convert it to Arrow objects.
+ * This method uses the default Calendar instance with default TimeZone and Locale as returned by the JVM.
+ * If you wish to use specific TimeZone or Locale for any Date, Time and Timestamp datasets, you may want use
+ * overloaded API that taken Calendar object instance.
+ *
+ * @param connection Database connection to be used. This method will not close the passed connection object. Since
+ * the caller has passed the connection object it's the responsibility of the caller to close or
+ * return the connection to the pool.
+ * @param query The DB Query to fetch the data.
+ * @param allocator Memory allocator
+ * @return Arrow Data Objects {@link VectorSchemaRoot}
+ * @throws SQLException Propagate any SQL Exceptions to the caller after closing any resources opened such as
+ * ResultSet and Statement objects.
+ */
+ public static VectorSchemaRoot sqlToArrow(Connection connection, String query, BufferAllocator allocator)
+ throws SQLException, IOException {
+ Preconditions.checkNotNull(allocator, "Memory allocator object can not be null");
+
+ JdbcToArrowConfig config =
+ new JdbcToArrowConfig(allocator, JdbcToArrowUtils.getUtcCalendar());
+ return sqlToArrow(connection, query, config);
+ }
+
+ /**
+ * For the given SQL query, execute and fetch the data from Relational DB and convert it to Arrow objects.
+ *
+ * @param connection Database connection to be used. This method will not close the passed connection object. Since
+ * the caller has passed the connection object it's the responsibility of the caller to close or
+ * return the connection to the pool.
+ * @param query The DB Query to fetch the data.
+ * @param allocator Memory allocator
+ * @param calendar Calendar object to use to handle Date, Time and Timestamp datasets.
+ * @return Arrow Data Objects {@link VectorSchemaRoot}
+ * @throws SQLException Propagate any SQL Exceptions to the caller after closing any resources opened such as
+ * ResultSet and Statement objects.
+ */
+ public static VectorSchemaRoot sqlToArrow(
+ Connection connection,
+ String query,
+ BufferAllocator allocator,
+ Calendar calendar) throws SQLException, IOException {
+
+ Preconditions.checkNotNull(allocator, "Memory allocator object can not be null");
+ Preconditions.checkNotNull(calendar, "Calendar object can not be null");
+
+ return sqlToArrow(connection, query, new JdbcToArrowConfig(allocator, calendar));
+ }
+
+ /**
+ * For the given SQL query, execute and fetch the data from Relational DB and convert it to Arrow objects.
+ *
+ * @param connection Database connection to be used. This method will not close the passed connection object.
+ * Since the caller has passed the connection object it's the responsibility of the caller
+ * to close or return the connection to the pool.
+ * @param query The DB Query to fetch the data.
+ * @param config Configuration
+ * @return Arrow Data Objects {@link VectorSchemaRoot}
+ * @throws SQLException Propagate any SQL Exceptions to the caller after closing any resources opened such as
+ * ResultSet and Statement objects.
+ */
+ public static VectorSchemaRoot sqlToArrow(Connection connection, String query, JdbcToArrowConfig config)
+ throws SQLException, IOException {
+ Preconditions.checkNotNull(connection, "JDBC connection object can not be null");
+ Preconditions.checkArgument(query != null && query.length() > 0, "SQL query can not be null or empty");
+
+ try (Statement stmt = connection.createStatement()) {
+ return sqlToArrow(stmt.executeQuery(query), config);
+ }
+ }
+
+ /**
+ * For the given JDBC {@link ResultSet}, fetch the data from Relational DB and convert it to Arrow objects. This
+ * method uses the default RootAllocator and Calendar object.
+ *
+ * @param resultSet ResultSet to use to fetch the data from underlying database
+ * @return Arrow Data Objects {@link VectorSchemaRoot}
+ * @throws SQLException on error
+ */
+ public static VectorSchemaRoot sqlToArrow(ResultSet resultSet) throws SQLException, IOException {
+ Preconditions.checkNotNull(resultSet, "JDBC ResultSet object can not be null");
+
+ return sqlToArrow(resultSet, JdbcToArrowUtils.getUtcCalendar());
+ }
+
+ /**
+ * For the given JDBC {@link ResultSet}, fetch the data from Relational DB and convert it to Arrow objects.
+ *
+ * @param resultSet ResultSet to use to fetch the data from underlying database
+ * @param allocator Memory allocator
+ * @return Arrow Data Objects {@link VectorSchemaRoot}
+ * @throws SQLException on error
+ */
+ public static VectorSchemaRoot sqlToArrow(ResultSet resultSet, BufferAllocator allocator)
+ throws SQLException, IOException {
+ Preconditions.checkNotNull(allocator, "Memory Allocator object can not be null");
+
+ JdbcToArrowConfig config =
+ new JdbcToArrowConfig(allocator, JdbcToArrowUtils.getUtcCalendar());
+ return sqlToArrow(resultSet, config);
+ }
+
+ /**
+ * For the given JDBC {@link ResultSet}, fetch the data from Relational DB and convert it to Arrow objects.
+ *
+ * @param resultSet ResultSet to use to fetch the data from underlying database
+ * @param calendar Calendar instance to use for Date, Time and Timestamp datasets, or null if none.
+ * @return Arrow Data Objects {@link VectorSchemaRoot}
+ * @throws SQLException on error
+ */
+ public static VectorSchemaRoot sqlToArrow(ResultSet resultSet, Calendar calendar) throws SQLException, IOException {
+ Preconditions.checkNotNull(resultSet, "JDBC ResultSet object can not be null");
+ return sqlToArrow(resultSet, new JdbcToArrowConfig(new RootAllocator(Integer.MAX_VALUE), calendar));
+ }
+
+ /**
+ * For the given JDBC {@link ResultSet}, fetch the data from Relational DB and convert it to Arrow objects.
+ *
+ * @param resultSet ResultSet to use to fetch the data from underlying database
+ * @param allocator Memory allocator to use.
+ * @param calendar Calendar instance to use for Date, Time and Timestamp datasets, or null if none.
+ * @return Arrow Data Objects {@link VectorSchemaRoot}
+ * @throws SQLException on error
+ */
+ public static VectorSchemaRoot sqlToArrow(
+ ResultSet resultSet,
+ BufferAllocator allocator,
+ Calendar calendar)
+ throws SQLException, IOException {
+ Preconditions.checkNotNull(allocator, "Memory Allocator object can not be null");
+
+ return sqlToArrow(resultSet, new JdbcToArrowConfig(allocator, calendar));
+ }
+
+ /**
+ * For the given JDBC {@link ResultSet}, fetch the data from Relational DB and convert it to Arrow objects.
+ *
+ * @param resultSet ResultSet to use to fetch the data from underlying database
+ * @param config Configuration of the conversion from JDBC to Arrow.
+ * @return Arrow Data Objects {@link VectorSchemaRoot}
+ * @throws SQLException on error
+ */
+ public static VectorSchemaRoot sqlToArrow(ResultSet resultSet, JdbcToArrowConfig config)
+ throws SQLException, IOException {
+ Preconditions.checkNotNull(resultSet, "JDBC ResultSet object can not be null");
+ Preconditions.checkNotNull(config, "The configuration cannot be null");
+
+ VectorSchemaRoot root = VectorSchemaRoot.create(
+ JdbcToArrowUtils.jdbcToArrowSchema(resultSet.getMetaData(), config), config.getAllocator());
+ if (config.getTargetBatchSize() != JdbcToArrowConfig.NO_LIMIT_BATCH_SIZE) {
+ ValueVectorUtility.preAllocate(root, config.getTargetBatchSize());
+ }
+ JdbcToArrowUtils.jdbcToArrowVectors(resultSet, root, config);
+ return root;
+ }
+
}
diff --git a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcAliasToArrowTest.java b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcAliasToArrowTest.java
index f44818a9f09..a6e6b22fcb4 100644
--- a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcAliasToArrowTest.java
+++ b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcAliasToArrowTest.java
@@ -17,6 +17,7 @@
package org.apache.arrow.adapter.jdbc.h2;
+import static org.apache.arrow.adapter.jdbc.AbstractJdbcToArrowTest.sqlToArrow;
import static org.junit.Assert.assertEquals;
import java.sql.Connection;
@@ -28,7 +29,6 @@
import java.sql.Statement;
import java.util.List;
-import org.apache.arrow.adapter.jdbc.JdbcToArrow;
import org.apache.arrow.memory.RootAllocator;
import org.apache.arrow.vector.VectorSchemaRoot;
import org.apache.arrow.vector.types.pojo.Field;
@@ -106,7 +106,7 @@ public void testJdbcAliasToArrow() throws Exception {
try (ResultSet resultSet = conn.createStatement().executeQuery(QUERY)) {
final VectorSchemaRoot vector =
- JdbcToArrow.sqlToArrow(resultSet, new RootAllocator(Integer.MAX_VALUE));
+ sqlToArrow(resultSet, new RootAllocator(Integer.MAX_VALUE));
assertEquals(rowCount, vector.getRowCount());
Schema vectorSchema = vector.getSchema();
diff --git a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowArrayTest.java b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowArrayTest.java
index 31f7db549e9..cff14c84395 100644
--- a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowArrayTest.java
+++ b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowArrayTest.java
@@ -17,6 +17,7 @@
package org.apache.arrow.adapter.jdbc.h2;
+import static org.apache.arrow.adapter.jdbc.AbstractJdbcToArrowTest.sqlToArrow;
import static org.junit.Assert.*;
import java.sql.Array;
@@ -32,7 +33,6 @@
import java.util.Map;
import org.apache.arrow.adapter.jdbc.JdbcFieldInfo;
-import org.apache.arrow.adapter.jdbc.JdbcToArrow;
import org.apache.arrow.adapter.jdbc.JdbcToArrowConfig;
import org.apache.arrow.adapter.jdbc.JdbcToArrowConfigBuilder;
import org.apache.arrow.adapter.jdbc.JdbcToArrowUtils;
@@ -160,7 +160,7 @@ public void testJdbcToArrow() throws Exception {
final JdbcToArrowConfig config = builder.build();
try (ResultSet resultSet = conn.createStatement().executeQuery(QUERY)) {
- final VectorSchemaRoot vector = JdbcToArrow.sqlToArrow(resultSet, config);
+ final VectorSchemaRoot vector = sqlToArrow(resultSet, config);
assertEquals(rowCount, vector.getRowCount());
@@ -204,7 +204,7 @@ public void testJdbcToArrowWithNulls() throws Exception {
final JdbcToArrowConfig config = builder.build();
try (ResultSet resultSet = conn.createStatement().executeQuery(QUERY)) {
- final VectorSchemaRoot vector = JdbcToArrow.sqlToArrow(resultSet, config);
+ final VectorSchemaRoot vector = sqlToArrow(resultSet, config);
assertEquals(rowCount, vector.getRowCount());
diff --git a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowCharSetTest.java b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowCharSetTest.java
index b2ac349b596..b548c9169af 100644
--- a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowCharSetTest.java
+++ b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowCharSetTest.java
@@ -31,7 +31,6 @@
import java.util.Collection;
import org.apache.arrow.adapter.jdbc.AbstractJdbcToArrowTest;
-import org.apache.arrow.adapter.jdbc.JdbcToArrow;
import org.apache.arrow.adapter.jdbc.JdbcToArrowConfig;
import org.apache.arrow.adapter.jdbc.JdbcToArrowConfigBuilder;
import org.apache.arrow.adapter.jdbc.JdbcToArrowTestHelper;
@@ -109,20 +108,20 @@ public static Collection