Skip to content

Conversation

aiguofer
Copy link
Contributor

@aiguofer aiguofer commented Sep 24, 2025

What's Changed

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)

This PR changes the value we store in the exception to be the MinorType instead so we can still get useful info about the type but avoiding this possible exception.

Closes #858.

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)
```
@aiguofer aiguofer changed the title Fix error handling in CompositeJdbcConsumer GH-858 Fix error handling in CompositeJdbcConsumer Sep 24, 2025
@aiguofer aiguofer changed the title GH-858 Fix error handling in CompositeJdbcConsumer GH-858: Fix error handling in CompositeJdbcConsumer Sep 24, 2025
Copy link
Member

@lidavidm lidavidm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically this is a breaking change, not that I expect anyone to actually be constructing this exception themselves...


throw new JdbcConsumerException(
"Exception while consuming JDBC value", e, fieldInfo, arrowType);
"Exception while consuming JDBC value", e, fieldInfo, consumer.vector.getMinorType());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just vector.getField()? That'd be even better (you get the field name and type)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to guess the original author relied a little too hard on IDE autocomplete and saw getMinorType but not getField

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha I was the original author! 😂 As long as I've been working with Arrow in Java now, I can't say I fully understand all the different abstractions and their differences, so it's very likely getMinorType was the only thing I saw in auto-complete related to type.... But I definitely think Field would be better here! thanks for the suggestion

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, oops, sorry about that 😬

To be fair, I do think it's weird that we have a getMinorType but not a getType

Copy link
Member

@lidavidm lidavidm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@lidavidm lidavidm merged commit ec3a424 into apache:main Sep 25, 2025
18 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception thrown while handling exception in CompositeJdbcConsumer
2 participants