首页 > 解决方案 > 无法在 spark 中配置自定义 hive-metastore-client

问题描述

我们在使用 spark 和 hive 时面临一些挑战。我们需要从 spark 连接到 hive-metastore,并且我们必须在 spark 中使用自定义的 hive-metastore-client。代码片段:

spark = SparkSession \
    .builder \
        .config('spark.sql.hive.metastore.version','3.1.2' ) \
        .config('spark.sql.hive.metastore.jars', 'hive-standalone-metastore-3.1.2-sqlquery.jar') \
        .config("spark.yarn.dist.jars", "hive-exec-3.1.2.jar") \
        .config('hive.metastore.uris', "thrift://localhost:9090") \

上面的代码适用于内置的 hive-metastore-client,但由于自定义错误而失败:

py4j.protocol.Py4JJavaError: 调用 o79.databaseExists 时出错。:java.lang.NoClassDefFoundError:org/apache/hadoop/hive/ql/metadata/HiveException

引起:java.lang.ClassNotFoundException:org.apache.hadoop.hive.ql.metadata.HiveException

为了解决这个问题,我们在代码中配置了自定义 hive-exec 并尝试使用命令行传递:

但是问题还没有解决,任何建议都会对我们有所帮助。

标签: apache-sparkhivehive-metastore

解决方案


推荐阅读