toddfarmer commented on code in PR #13543:
URL: https://github.com/apache/arrow/pull/13543#discussion_r919192109


##########
docs/source/java/jdbc.rst:
##########
@@ -0,0 +1,169 @@
+.. Licensed to the Apache Software Foundation (ASF) under one
+.. or more contributor license agreements.  See the NOTICE file
+.. distributed with this work for additional information
+.. regarding copyright ownership.  The ASF licenses this file
+.. to you under the Apache License, Version 2.0 (the
+.. "License"); you may not use this file except in compliance
+.. with the License.  You may obtain a copy of the License at
+
+..   http://www.apache.org/licenses/LICENSE-2.0
+
+.. Unless required by applicable law or agreed to in writing,
+.. software distributed under the License is distributed on an
+.. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+.. KIND, either express or implied.  See the License for the
+.. specific language governing permissions and limitations
+.. under the License.
+
+==================
+Arrow JDBC Adapter
+==================
+
+The Arrow JDBC Adapter assists with working with JDBC and Arrow
+data. Currently, it supports reading JDBC ResultSets into Arrow
+VectorSchemaRoots.
+
+ResultSet to VectorSchemaRoot Conversion
+========================================
+
+This can be accessed via the JdbcToArrow class. The resulting
+ArrowVectorIterator will convert a ResultSet to Arrow data in batches
+of rows.
+
+.. code-block:: java
+
+   try (ArrowVectorIterator it = 
JdbcToArrow.sqlToArrowVectorIterator(resultSet, allocator)) {
+     while (it.hasNext()) {
+       VectorSchemaRoot root = it.next();
+       // Consume the root…
+     }
+   }
+
+The batch size and type mapping can both be customized:
+
+.. code-block:: java
+
+   JdbcToArrowConfig config = new JdbcToArrowConfigBuilder(allocator, 
/*calendar=*/null)
+       .setReuseVectorSchemaRoot(reuseVectorSchemaRoot)
+       .setJdbcToArrowTypeConverter((jdbcFieldInfo -> {
+         switch (jdbcFieldInfo.getJdbcType()) {
+           case Types.BIGINT:
+             // Assume actual value range is SMALLINT
+             return new ArrowType.Int(16, true);
+           default:
+             return null;
+         }
+       }))
+       .build();
+   try (ArrowVectorIterator iter = JdbcToArrow.sqlToArrowVectorIterator(rs, 
config)) {
+     while (iter.hasNext()) {
+       VectorSchemaRoot root = iter.next();
+       // Consume the root…
+     }
+   }
+
+The JDBC type can be explicitly specified, which is useful since JDBC
+drivers can give spurious type information. For example, the Postgres
+driver has been observed to use Decimal types with scale and precision

Review Comment:
   Do we want to say anything about the behavior in the event of 
precision/scale mismatches? Specifically, different precision is allowed when 
the target precision is greater than the source. Scale must match exactly, 
unless an explicit RoundingMode is defined.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to