【发布时间】:2018-05-27 12:39:58
【问题描述】:
我有一个简单的 Spark 项目,我尝试使用 sbt run 运行它。但是在代码生成期间会导致异常:
17/12/13 15:19:27 ERROR CodeGenerator: failed to compile: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 15, Column 34: Cannot determine simple type name "scala"
/* 001 */ public Object generate(Object[] references) {
/* 002 */ return new GeneratedIterator(references);
/* 003 */ }
/* 004 */
/* 005 */ final class GeneratedIterator extends org.apache.spark.sql.execution.BufferedRowIterator {
/* 006 */ private Object[] references;
/* 007 */ private scala.collection.Iterator[] inputs;
/* 008 */ private org.apache.spark.sql.execution.metric.SQLMetric scan_numOutputRows;
/* 009 */ private scala.collection.Iterator scan_input;
/* 010 */
/* 011 */ public GeneratedIterator(Object[] references) {
/* 012 */ this.references = references;
/* 013 */ }
/* 014 */
/* 015 */ public void init(int index, scala.collection.Iterator[] inputs) {
/* 016 */ partitionIndex = index;
/* 017 */ this.inputs = inputs;
/* 018 */ this.scan_numOutputRows = (org.apache.spark.sql.execution.metric.SQLMetric) references[0];
/* 019 */ scan_input = inputs[0];
/* 020 */
/* 021 */ }
/* 022 */
/* 023 */ protected void processNext() throws java.io.IOException {
/* 024 */ while (scan_input.hasNext()) {
/* 025 */ InternalRow scan_row = (InternalRow) scan_input.next();
/* 026 */ scan_numOutputRows.add(1);
/* 027 */ append(scan_row);
/* 028 */ if (shouldStop()) return;
/* 029 */ }
/* 030 */ }
/* 031 */ }
org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 15, Column 34: Cannot determine simple type name "scala"
spark-submit 不会发生这种情况。构建定义最少:
name := "untitled"
version := "0.1"
scalaVersion := "2.11.12"
libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-sql" % "2.2.1"
)
代码也是如此(我会发布它,有人认为它是相关的,但我认为问题是一般性的)和build.properties:
sbt.version = 1.0.4
据我了解,这是因为 Spark 在运行时找不到 Scala 库 - 这是正确的吗?
【问题讨论】:
标签: scala apache-spark sbt apache-spark-sql