You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-zh@flink.apache.org by liuyehan <ly...@163.com> on 2021/11/11 01:49:50 UTC

flink 1.10 sql 读写 hive 2.1.0

您好!


    感谢您百忙之中抽空看我邮件;
目前问题:
使用看flink 1.10官网 hive部分,出现了Exception in thread "main" java.lang.IncompatibleClassChangeError: Implementing class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)


pom.xml:
<dependency>
    <groupId>org.apache.flink</groupId>
    <artifactId>flink-connector-hive_2.11</artifactId>
    <version>1.10.2</version>
    <scope>provided</scope>
</dependency>

<dependency>
    <groupId>org.apache.flink</groupId>
    <artifactId>flink-table-api-java-bridge_2.11</artifactId>
    <version>1.10.2</version>
    <scope>provided</scope>
</dependency>

<!-- Hive Dependency -->
<dependency>
    <groupId>org.apache.hive</groupId>
    <artifactId>hive-exec</artifactId>
    <version>2.1.0</version>
    <scope>provided</scope>
</dependency>


代码:
 EnvironmentSettings settings = EnvironmentSettings.newInstance().useBlinkPlanner().inBatchMode().build();
TableEnvironment tableEnv = TableEnvironment.create(settings);

//EnvironmentSettings settings = EnvironmentSettings.newInstance().useBlinkPlanner().inBatchMode().build();

       // TableEnvironment tableEnv = TableEnvironment.create(settings);

String name            = "myhive";
String defaultDatabase = "default";
String hiveConfDir     = "/export/server/hive-2.1.0/conf";

HiveCatalog hive = new HiveCatalog(name, defaultDatabase, hiveConfDir,"2.1.0");
tableEnv.registerCatalog("myhive", hive);

// set the HiveCatalog as the current catalog of the session
tableEnv.useCatalog("myhive");
Table result = tableEnv.sqlQuery("select * from exp_2_mysql_table limit 10");
result.printSchema();

tableEnv.execute("Flink SQL");