The main issue is that since Flink 2.0 is Java 11+, and Hive 3 doesn't work 
beyond Java 8, Flink 2.0+ won't work with Hive 3. Is this something that we can 
live with.

The workaround is a bit hacky. It requires faking the current thread context 
class loader to be compatible with Hive 3 

On 4/14/26, 11:55 AM, "Martijn Visser" <[email protected] 
<mailto:[email protected]>> wrote:


CAUTION: This email originated from outside of the organization. Do not click 
links or open attachments unless you can confirm the sender and know the 
content is safe.






Hi Jayesh,


Thanks for the message. On your question "Should the Flink Hive connector
work around this for Hive 3.1 users?" the answer is probably "it depends".
Without proper support for newer Java versions, I wouldn't expect this to
work beyond Java 8 to be honest.


Best regards,


Martijn


On Mon, Apr 13, 2026 at 9:08 PM Lalwani, Jayesh <[email protected] 
<mailto:[email protected]>> wrote:


> Hi devs,
>
> While working on adapting the external Hive connector for Flink 2.0
> (FLINK-37094), we discovered that the Hive 3.1 profile (-Phive3) is
> broken on Java 9+ due to a bug in Hive's SessionState constructor.
>
> ## Problem
>
> Hive 3.1's SessionState (line 413) casts the system classloader to
> URLClassLoader:
>
> (URLClassLoader) Thread.currentThread().getContextClassLoader()
>
> On Java 9+, the application classloader is
> jdk.internal.loader.ClassLoaders$AppClassLoader, which does not extend
> URLClassLoader. This causes a ClassCastException on any code path that
> initializes SessionState — including HiveParser, HiveDialect, and
> HiveDynamicTableFactory.
>
> Since Flink 2.0 requires Java 11+, this means Hive 3.1 dialect/parser
> features are completely broken on Flink 2.0.
>
> 25 tests fail in the Hive 3.1 profile on Java 11+:
> - HiveDynamicTableFactoryTest (4)
> - HiveTableSourceStatisticsReportTest (8)
> - HiveTableCompactSinkParallelismTest (4)
> - HiveSourceTest (4)
> - HiveDialectSupportSQL11ReservedKeywordAsIdentifierITTest (3)
> - HiveDialectQueryPlanTest (1)
> - HiveFunctionWrapperTest (1)
>
> The Hive 2.3 profile is unaffected.
>
> ## Upstream status
>
> This is a known Hive bug (HIVE-21584 [1]), fixed in Hive 4.0 via
> HIVE-27508 [2]. The fix replaces the URLClassLoader cast with
> SessionState.class.getClassLoader(). Hive 3.1 is EOL and will not
> receive a backport.
>
> ## Reproducing
>
> On the current main branch with Java 11+:
>
> JAVA_HOME=/path/to/java-11 mvn verify \
> -pl flink-connector-hive -am -Phive3
>
> ## Question
>
> Should the Flink Hive connector work around this for Hive 3.1 users?
> One approach would be to wrap the thread context classloader in a
> URLClassLoader before calling new SessionState() in HiveSessionState.
> Alternatively, we could document Hive 3.1 as unsupported on Java 11+
> and recommend users upgrade to Hive 4.
>
> Thoughts?
>
> [1] https://issues.apache.org/jira/browse/HIVE-21584 
> <https://issues.apache.org/jira/browse/HIVE-21584>
> [2] https://issues.apache.org/jira/browse/HIVE-27508 
> <https://issues.apache.org/jira/browse/HIVE-27508>
>
> Best,
> Jayesh
>



Reply via email to