使用HiveRunner进行单元测试中的MissingTableException

时间:2020-04-14 07:15:53

标签: java maven junit hive

我有一个来自-https://github.com/klarna/HiveRunner/blob/master/src/test/java/com/klarna/hiverunner/ExecuteScriptIntegrationTest.java的简单的hiverunner测试,我想将其添加到我的多模块maven项目中。 添加测试,资源,插件和依赖项后,我得到了一个例外。我试图创建新的Maven项目并将其添加到其中。它工作成功。我试图执行mvn dependency:tree并比较结果。

2020-04-13T21:11:16,626 WARN  DataNucleus.Query:106 - Query for candidates of org.apache.hadoop.hive.metastore.model.MDatabase and subclasses resulted in no possible candidates
org.datanucleus.store.rdbms.exceptions.MissingTableException: Required table missing : "DBS" in Catalog "" Schema "". DataNucleus requires this table to perform its persistence operations. Either your MetaData is incorrect, or you need to enable "datanucleus.autoCreateTables"

您能帮我解决这个问题吗?

pom.xml包含

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>8</source>
                <target>8</target>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>com.klarna</groupId>
        <artifactId>hiverunner</artifactId>
        <version>5.1.1</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

工作项目包含下一个:

+- org.apache.hive:hive-jdbc:jar:2.3.6:compile
[INFO] |  |  +- org.apache.hive:hive-metastore:jar:2.3.6:compile
[INFO] |  |  |  +- javolution:javolution:jar:5.5.1:compile
[INFO] |  |  |  +- org.apache.hbase:hbase-client:jar:1.1.1:compile
[INFO] |  |  |  |  +- org.apache.hbase:hbase-annotations:jar:1.1.1:compile
[INFO] |  |  |  |  +- org.apache.hbase:hbase-protocol:jar:1.1.1:compile
[INFO] |  |  |  |  +- io.netty:netty-all:jar:4.0.23.Final:compile
[INFO] |  |  |  |  +- org.jruby.jcodings:jcodings:jar:1.0.8:compile
[INFO] |  |  |  |  +- org.jruby.joni:joni:jar:2.1.2:compile
[INFO] |  |  |  |  \- com.github.stephenc.findbugs:findbugs-annotations:jar:1.3.9-1:compile
[INFO] |  |  |  +- com.jolbox:bonecp:jar:0.8.0.RELEASE:compile

无效版本包含

|  +- org.apache.hive:hive-jdbc:jar:1.2.1:compile
[INFO] |  |  +- org.apache.hive:hive-metastore:jar:1.2.1:compile
[INFO] |  |  |  +- com.jolbox:bonecp:jar:0.8.0.RELEASE:compile
[INFO] |  |  |  +- org.apache.derby:derby:jar:10.10.2.0:compile
[INFO] |  |  |  +- org.datanucleus:datanucleus-api-jdo:jar:3.2.6:compile
[INFO] |  |  |  +- org.datanucleus:datanucleus-core:jar:3.2.10:compile
[INFO] |  |  |  +- org.datanucleus:datanucleus-rdbms:jar:3.2.9:compile
[INFO] |  |  |  +- commons-pool:commons-pool:jar:1.5.4:compile
[INFO] |  |  |  +- commons-dbcp:commons-dbcp:jar:1.4:compile
[INFO] |  |  |  +- javax.jdo:jdo-api:jar:3.0.1:compile
[INFO] |  |  |  |  \- javax.transaction:jta:jar:1.1:compile

working project

not working project

1 个答案:

答案 0 :(得分:0)

您应该运行$HIVE_HOME\scripts\metastore\upgrade\mysql中提到的配置单元模式.sql脚本。

注意:我使用MySql作为蜂巢的基础数据库。