Skip to content

Commit 9bb4214

Browse files
committed
Fix error handling in CompositeJdbcConsumer
Turns out not all MinorTypes have a corresponding ArrowType, which can cause the following exception while handling the original exception: ``` Caused by: java.lang.UnsupportedOperationException: Cannot get simple type for type DECIMAL at org.apache.arrow.vector.types.Types$MinorType.getType(Types.java:815) at org.apache.arrow.adapter.jdbc.consumer.CompositeJdbcConsumer.consume(CompositeJdbcConsumer.java:49) ```
1 parent e026f3c commit 9bb4214

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/consumer/CompositeJdbcConsumer.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.apache.arrow.util.AutoCloseables;
2525
import org.apache.arrow.vector.ValueVector;
2626
import org.apache.arrow.vector.VectorSchemaRoot;
27-
import org.apache.arrow.vector.types.pojo.ArrowType;
2827

2928
/** Composite consumer which hold all consumers. It manages the consume and cleanup process. */
3029
public class CompositeJdbcConsumer implements JdbcConsumer {
@@ -46,9 +45,9 @@ public void consume(ResultSet rs) throws SQLException, IOException {
4645
BaseConsumer consumer = (BaseConsumer) consumers[i];
4746
JdbcFieldInfo fieldInfo =
4847
new JdbcFieldInfo(rs.getMetaData(), consumer.columnIndexInResultSet);
49-
ArrowType arrowType = consumer.vector.getMinorType().getType();
48+
5049
throw new JdbcConsumerException(
51-
"Exception while consuming JDBC value", e, fieldInfo, arrowType);
50+
"Exception while consuming JDBC value", e, fieldInfo, consumer.vector.getMinorType());
5251
} else {
5352
throw e;
5453
}

adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/consumer/exceptions/JdbcConsumerException.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,33 @@
1717
package org.apache.arrow.adapter.jdbc.consumer.exceptions;
1818

1919
import org.apache.arrow.adapter.jdbc.JdbcFieldInfo;
20-
import org.apache.arrow.vector.types.pojo.ArrowType;
20+
import org.apache.arrow.vector.types.Types;
2121

2222
/**
2323
* Exception while consuming JDBC data. This exception stores the JdbcFieldInfo for the column and
2424
* the ArrowType for the corresponding vector for easier debugging.
2525
*/
2626
public class JdbcConsumerException extends RuntimeException {
2727
final JdbcFieldInfo fieldInfo;
28-
final ArrowType arrowType;
28+
final Types.MinorType minorType;
2929

3030
/**
3131
* Construct JdbcConsumerException with all fields.
3232
*
3333
* @param message error message
3434
* @param cause original exception
3535
* @param fieldInfo JdbcFieldInfo for the column
36-
* @param arrowType ArrowType for the corresponding vector
36+
* @param minorType ArrowType for the corresponding vector
3737
*/
3838
public JdbcConsumerException(
39-
String message, Throwable cause, JdbcFieldInfo fieldInfo, ArrowType arrowType) {
39+
String message, Throwable cause, JdbcFieldInfo fieldInfo, Types.MinorType minorType) {
4040
super(message, cause);
4141
this.fieldInfo = fieldInfo;
42-
this.arrowType = arrowType;
42+
this.minorType = minorType;
4343
}
4444

45-
public ArrowType getArrowType() {
46-
return this.arrowType;
45+
public Types.MinorType getMinorType() {
46+
return this.minorType;
4747
}
4848

4949
public JdbcFieldInfo getFieldInfo() {

0 commit comments

Comments
 (0)