@@ -89,7 +89,9 @@ public static VectorSchemaRoot sqlToArrow(Connection connection, String query, B
8989 Preconditions .checkArgument (query != null && query .length () > 0 , "SQL query can not be null or empty" );
9090 Preconditions .checkNotNull (allocator , "Memory allocator object can not be null" );
9191
92- return sqlToArrow (connection , query , allocator , Calendar .getInstance (TimeZone .getTimeZone ("UTC" ), Locale .ROOT ));
92+ JdbcToArrowConfig config =
93+ new JdbcToArrowConfig (allocator , Calendar .getInstance (TimeZone .getTimeZone ("UTC" ), Locale .ROOT ));
94+ return sqlToArrow (connection , query , config );
9395 }
9496
9597 /**
@@ -115,8 +117,18 @@ public static VectorSchemaRoot sqlToArrow(
115117 Preconditions .checkNotNull (allocator , "Memory allocator object can not be null" );
116118 Preconditions .checkNotNull (calendar , "Calendar object can not be null" );
117119
120+ return sqlToArrow (connection , query , new JdbcToArrowConfig (allocator , calendar ));
121+ }
122+
123+ public static VectorSchemaRoot sqlToArrow (Connection connection , String query , JdbcToArrowConfig config )
124+ throws SQLException , IOException {
125+ Preconditions .checkNotNull (connection , "JDBC connection object can not be null" );
126+ Preconditions .checkArgument (query != null && query .length () > 0 , "SQL query can not be null or empty" );
127+ Preconditions .checkNotNull (config , "The configuration cannot be null" );
128+ Preconditions .checkArgument (config .isValid (), "The configuration must be valid" );
129+
118130 try (Statement stmt = connection .createStatement ()) {
119- return sqlToArrow (stmt .executeQuery (query ), allocator , calendar );
131+ return sqlToArrow (stmt .executeQuery (query ), config );
120132 }
121133 }
122134
@@ -147,7 +159,9 @@ public static VectorSchemaRoot sqlToArrow(ResultSet resultSet, BaseAllocator all
147159 Preconditions .checkNotNull (resultSet , "JDBC ResultSet object can not be null" );
148160 Preconditions .checkNotNull (allocator , "Memory Allocator object can not be null" );
149161
150- return sqlToArrow (resultSet , allocator , Calendar .getInstance (TimeZone .getTimeZone ("UTC" ), Locale .ROOT ));
162+ JdbcToArrowConfig config =
163+ new JdbcToArrowConfig (allocator , Calendar .getInstance (TimeZone .getTimeZone ("UTC" ), Locale .ROOT ));
164+ return sqlToArrow (resultSet , config );
151165 }
152166
153167 /**
@@ -162,10 +176,7 @@ public static VectorSchemaRoot sqlToArrow(ResultSet resultSet, Calendar calendar
162176 Preconditions .checkNotNull (resultSet , "JDBC ResultSet object can not be null" );
163177 Preconditions .checkNotNull (calendar , "Calendar object can not be null" );
164178
165- RootAllocator rootAllocator = new RootAllocator (Integer .MAX_VALUE );
166- VectorSchemaRoot root = sqlToArrow (resultSet , rootAllocator , calendar );
167-
168- return root ;
179+ return sqlToArrow (resultSet , new JdbcToArrowConfig (new RootAllocator (Integer .MAX_VALUE ), calendar ));
169180 }
170181
171182 /**
@@ -183,9 +194,18 @@ public static VectorSchemaRoot sqlToArrow(ResultSet resultSet, BaseAllocator all
183194 Preconditions .checkNotNull (allocator , "Memory Allocator object can not be null" );
184195 Preconditions .checkNotNull (calendar , "Calendar object can not be null" );
185196
197+ return sqlToArrow (resultSet , new JdbcToArrowConfig (allocator , calendar ));
198+ }
199+
200+ public static VectorSchemaRoot sqlToArrow (ResultSet resultSet , JdbcToArrowConfig config )
201+ throws SQLException , IOException {
202+ Preconditions .checkNotNull (resultSet , "JDBC ResultSet object can not be null" );
203+ Preconditions .checkNotNull (config , "The configuration cannot be null" );
204+ Preconditions .checkArgument (config .isValid (), "The configuration must be valid" );
205+
186206 VectorSchemaRoot root = VectorSchemaRoot .create (
187- JdbcToArrowUtils .jdbcToArrowSchema (resultSet .getMetaData (), calendar ), allocator );
188- JdbcToArrowUtils .jdbcToArrowVectors (resultSet , root , calendar );
207+ JdbcToArrowUtils .jdbcToArrowSchema (resultSet .getMetaData (), config . getCalendar ()), config . getAllocator () );
208+ JdbcToArrowUtils .jdbcToArrowVectors (resultSet , root , config . getCalendar () );
189209 return root ;
190210 }
191211}
0 commit comments