[JDBC] Exception handling for non-simple types swallows actual error during processing
- 主要語言
- Java
- 星號
- 94
- 分支
- 152
- 平均合併
- 3 天 16 小時
- 30 天內合併 PR
- 11
描述
### Describe the bug, including details regarding any error messages, version, and platform.
It appears as though apache/arrow#39356 added support for better error messages when an error is encountered during JDBC processing. However, some `MinorType` such as Decimal (and various others) do not have an associated ArrowType and throw an exception trying to get the additional information leading to the original error being suppressed.
Decimal MinorType:
https://github.com/apache/arrow/blob/main/java/vector/src/main/java/org/apache/arrow/vector/types/Types.java#L583
Callsite for suppressing error:
https://github.com/apache/arrow/blob/main/java/vector/src/main/java/org/apache/arrow/vector/types/Types.java#L821
called from consumer (where minorType's arrow type is null)
https://github.com/apache/arrow/blob/main/java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/consumer/CompositeJdbcConsumer.java#L55
```
java.lang.RuntimeException: Error occurred while consuming data.
at org.apache.arrow.adapter.jdbc.ArrowVectorIterator.consumeData(ArrowVectorIterator.java:121)
at org.apache.arrow.adapter.jdbc.ArrowVectorIterator.load(ArrowVectorIterator.java:164)
at org.apache.arrow.adapter.jdbc.ArrowVectorIterator.next(ArrowVectorIterator.java:183)
...
Caused by: java.lang.UnsupportedOperationException: Cannot get simple type for type DECIMAL
at org.apache.arrow.vector.types.Types$MinorType.getType(Types.java:821)
at org.apache.arrow.adapter.jdbc.consumer.CompositeJdbcConsumer.consume(CompositeJdbcConsumer.java:55)
at org.apache.arrow.adapter.jdbc.ArrowVectorIterator.consumeData(ArrowVectorIterator.java:107)
... 95 more
```
suppressed error (via debugger):
```
java.lang.UnsupportedOperationException: BigDecimal precision cannot be greater than that in the Arrow vector: 39 > 38
at org.apache.arrow.vector.util.DecimalUtility.checkPrecisionAndScale(DecimalUtility.java:99)
at org.apache.arrow.vector.DecimalVector.set(DecimalVector.java:365)
at org.apache.arrow.adapter.jdbc.consumer.DecimalConsumer.set(DecimalConsumer.java:79)
at org.apache.arrow.adapter.jdbc.consumer.DecimalConsumer$NullableDecimalConsumer.consume(DecimalConsumer.java:101)
at org.apache.arrow.adapter.jdbc.consumer.CompositeJdbcConsumer.consume(CompositeJdbcConsumer.java:50)
at org.apache.arrow.adapter.jdbc.ArrowVectorIterator.consumeData(ArrowVectorIterator.java:107)
at org.apache.arrow.adapter.jdbc.ArrowVectorIterator.load(ArrowVectorIterator.java:164)
at org.apache.arrow.adapter.jdbc.ArrowVectorIterator.next(ArrowVectorIterator.java:183)
```
It is somewhat difficult to come up with a simple reproduction, but I getting this error by rounding decimals that should be too large to fit into a `decimal(38,10)` -- if a decimal exceeds this (such as the numeric value of `99999999999999999999999999999.9999999999` which requires 39 digits of precision) this error is thrown.
This is happening on version 15.0.0 and up. (was not occurring in 14.0.X and below).
### Component(s)
Java
貢獻指南
研究方向
從 CompositeJdbcConsumer.consume 開始,接著檢查 Types.java、DecimalConsumer.java 和 ArrowVectorIterator.consumeData,以追蹤原始 Decimal 精確度錯誤是如何被取代的。重現一個超過 decimal(38,10) 的 JDBC 值,並驗證處理程序回報的是底層精確度錯誤,而不是來自 MinorType.getType() 的 UnsupportedOperationException。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- java
- 領域
- databases
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100