@@ -89,7 +89,9 @@ public static VectorSchemaRoot sqlToArrow(Connection connection, String query, B
89
89
Preconditions .checkArgument (query != null && query .length () > 0 , "SQL query can not be null or empty" );
90
90
Preconditions .checkNotNull (allocator , "Memory allocator object can not be null" );
91
91
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 );
93
95
}
94
96
95
97
/**
@@ -115,8 +117,18 @@ public static VectorSchemaRoot sqlToArrow(
115
117
Preconditions .checkNotNull (allocator , "Memory allocator object can not be null" );
116
118
Preconditions .checkNotNull (calendar , "Calendar object can not be null" );
117
119
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
+
118
130
try (Statement stmt = connection .createStatement ()) {
119
- return sqlToArrow (stmt .executeQuery (query ), allocator , calendar );
131
+ return sqlToArrow (stmt .executeQuery (query ), config );
120
132
}
121
133
}
122
134
@@ -147,7 +159,9 @@ public static VectorSchemaRoot sqlToArrow(ResultSet resultSet, BaseAllocator all
147
159
Preconditions .checkNotNull (resultSet , "JDBC ResultSet object can not be null" );
148
160
Preconditions .checkNotNull (allocator , "Memory Allocator object can not be null" );
149
161
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 );
151
165
}
152
166
153
167
/**
@@ -162,10 +176,7 @@ public static VectorSchemaRoot sqlToArrow(ResultSet resultSet, Calendar calendar
162
176
Preconditions .checkNotNull (resultSet , "JDBC ResultSet object can not be null" );
163
177
Preconditions .checkNotNull (calendar , "Calendar object can not be null" );
164
178
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 ));
169
180
}
170
181
171
182
/**
@@ -183,9 +194,18 @@ public static VectorSchemaRoot sqlToArrow(ResultSet resultSet, BaseAllocator all
183
194
Preconditions .checkNotNull (allocator , "Memory Allocator object can not be null" );
184
195
Preconditions .checkNotNull (calendar , "Calendar object can not be null" );
185
196
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
+
186
206
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 () );
189
209
return root ;
190
210
}
191
211
}
0 commit comments