我正在尝试创建两个数据帧并使用dataframe.join方法连接它。
以下是scala代码:
import org.apache.spark.sql.SparkSession
import org.apache.spark.SparkConf
object RuleExecutor {
def main(args: Array[String]): Unit = {
val sparkConf = new SparkConf().setAppName(AppConstants.AppName).setMaster("local")
val sparkSession = SparkSession.builder().appName(AppConstants.AppName).config(sparkConf).enableHiveSupport().getOrCreate()
import sparkSession.sql
sql(s"CREATE DATABASE test")
sql ("CREATE TABLE test.box_width (id INT, width INT)") // Create table box_width
sql ("INSERT INTO test.box_width VALUES (1,1), (2,2)") // Insert data in box_width
sql ("CREATE TABLE test.box_length (id INT, length INT)") // Create table box_length
sql ("INSERT INTO test.box_length VALUES (1,10), (2,20)") // Insert data in box_length
val widthDF = sql("select * from test.box_width") // Get DF for table box_width
val lengthDF = sql("select * from test.box_length") // Get DF for table box_length
val dimensionDF = lengthDF.join(widthDF, "id"); // Joining
dimensionDF.show();
}
}但是在运行代码时,我得到了以下错误:
Exception in thread "main" java.lang.IllegalArgumentException: Error while instantiating 'org.apache.spark.sql.hive.HiveSessionStateBuilder':
at org.apache.spark.sql.SparkSession$.org$apache$spark$sql$SparkSession$$instantiateSessionState(SparkSession.scala:1062)…..
Caused by: org.apache.spark.sql.AnalysisException: java.lang.RuntimeException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient;
at org.apache.spark.sql.hive.HiveExternalCatalog.withClient(HiveExternalCatalog.scala:106)……
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:522)……
Caused by: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
at org.apache.hadoop.hive.metastore.MetaStoreUtils.newInstance(MetaStoreUtils.java:1523)……
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)…
Caused by: org.datanucleus.api.jdo.exceptions.ClassNotPersistenceCapableException: The class "org.apache.hadoop.hive.metastore.model.MVersionTable" is not persistable. This means that it either hasnt been enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the Meta-Data/annotations for the class are not found.
NestedThrowables:
org.datanucleus.exceptions.ClassNotPersistableException: The class "org.apache.hadoop.hive.metastore.model.MVersionTable" is not persistable. This means that it either hasnt been enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the Meta-Data/annotations for the class are not found.
at org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:473)……
Caused by: org.datanucleus.exceptions.ClassNotPersistableException: The class "org.apache.hadoop.hive.metastore.model.MVersionTable" is not persistable. This means that it either hasnt been enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the Meta-Data/annotations for the class are not found.
at org.datanucleus.ExecutionContextImpl.assertClassPersistable(ExecutionContextImpl.java:5113)……我使用的版本是
Scala = 2.11
Spark-hive = 2.2.2
Maven-org-spark-project-hive_hive-metastore = 1.x
DataNucleus = 5.x
如何解决此问题?complete log list of dependencies
谢谢
发布于 2018-10-03 23:56:03
首先,您不再需要在行尾使用;,除非在编写Scala代码时一行中有多个表达式。
其次,我查看了你的日志,有15个错误,主要是数据库表不在那里或找不到配置单元。所以我认为这些实例没有正确运行。在运行spark作业之前,您可以确保所有这些设置(配置单元、MySql DB)都设置正确吗?
https://stackoverflow.com/questions/52628227
复制相似问题