[英]Apache Zeppelin with Java error: ';' expected but 'class' found
I use Apache Spark's Java API to load data from some sources(like Cassandra and HDFS) for visualization in Apache Zeppelin. 我使用Apache Spark的Java API从某些源(例如Cassandra和HDFS)加载数据,以便在Apache Zeppelin中进行可视化。 The code is using SparkSql
and SparkSession
, not SparkContext
and tested successfully in IDE. 该代码使用的是SparkSql
和SparkSession
,而不是SparkContext
并且已在IDE中成功测试。 I paste the full code (containing all codes that I run in IDE) into Zeppelin notebook and after running it through an error error: ';' expected but 'class' found
我将完整代码(包含我在IDE中运行的所有代码)粘贴到Zeppelin笔记本中,并通过错误error: ';' expected but 'class' found
运行它error: ';' expected but 'class' found
error: ';' expected but 'class' found
. error: ';' expected but 'class' found
。 I think this error is a Scala error and I suspect does Zeppelin support Spark Java API?! 我认为此错误是Scala错误,我怀疑Zeppelin是否支持Spark Java API? If yes, how can I solve the problem? 是,如何解决?
Apache Zeppelin version: 0.7.3
The following is the code: Apache Zeppelin版本: 0.7.3
下面是代码:
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;
import java.util.HashMap;
public class LoadCSV {
public static void main(String[] args) {
HashMap<String, String> ops = new HashMap();
ops.put("table", "grades");
ops.put("keyspace", "zeppline");
SparkSession spark = SparkSession
.builder()
.master("local[*]")
.appName("Java Spark SQL basic example")
.config("spark.cassandra.connection.host", "127.0.0.1")
.config("spark.cassandra.connection.port", "9042")
.getOrCreate();
Dataset<Row> df1 = spark.read()
.format("csv")
.option("header", true)
.option("inferSchema", true)
.csv("hdfs://localhost:54310/Data/Zeppline/grades.csv");
Dataset<Row> df2 = spark.read()
.format("org.apache.spark.sql.cassandra")
.options(ops)
.load()
.select("id","first_name", "last_name", "ssn", "test1", "test2", "test3", "test4", "final", "grade");
df1.union(df2).createOrReplaceTempView("grades");
}
}
I suspect does Zeppelin support Spark JAVA API? 我怀疑齐柏林飞艇是否支持Spark JAVA API?
It does not. 它不是。 You can fin a full list of avialable interpreters on the Zeppelin website ( https://zeppelin.apache.org/docs/latest/manual/interpreters.html ) and there is no Java interpreter there. 您可以在Zeppelin网站( https://zeppelin.apache.org/docs/latest/manual/interpreters.html )上找到可用的解释器的完整列表,并且那里没有Java解释器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.