我正在使用Spark和scala,我也在使用aws胶水库以及胶水脚本。当我使用scala版本2.12时,我得到了这个错误。
import com.amazonaws.services.glue.{DataSource, DynamicFrame, GlueContext}
import com.amazonaws.services.glue.util.{GlueArgParser, Job, JsonOptions}
import org.apache.spark.{SparkConf, SparkContext}
import scala.collection.JavaConverters._
object Test {
def main(systemArgs: Array[String]): Unit = {
val conf = new SparkConf().setAppName("GlueExample").setMaster("local")
val sc = new SparkContext(conf)
sc.hadoopConfiguration.set("fs.s3.impl", "org.apache.hadoop.fs.s3a.S3AFileSystem")
val gc: GlueContext = new GlueContext(sc)
val connectionOptions = JsonOptions(Map(
"paths" -> Seq("s3://bucket_path"),
"groupFiles" -> "inPartition"
))
val source: DataSource = gc.getSourceWithFormat(
connectionType = "s3",
options = connectionOptions,
transformationContext = "",
format = "parquet",
formatOptions = JsonOptions.empty
)
}
}
在经历了这么多类似的问题之后,当我将scala版本改为2.11时,我得到了这个错误。error with 2.11 version
它甚至没有启动SparkConf()
我的build.gradle文件。
plugins {
id 'scala'
id 'java'
id 'application'
}
repositories {
maven { url 'https://repo1.maven.org/maven2/' }
mavenCentral()
maven { url 'https://aws-glue-etl-artifacts.s3.amazonaws.com/release/' }
}
dependencies {
implementation project(':diff-lib')
implementation 'org.scala-lang:scala-library'
implementation 'com.google.guava:guava'
implementation 'software.amazon.awssdk:glue'
implementation 'com.amazonaws:AWSGlueETL:1.0.0'
implementation "org.apache.spark:spark-core_$scalaVersion"
implementation 'org.slf4j:slf4j-log4j12
}
geadle.properties文件
gradleVersion=6.7
lombokVersion=1.18.10
awaitilityVersion=3.1.6
javaVersion=8
projectVersion=1.0.0
awsSdkVersion=2.16.44
junitVersion=5.7.1
log4jVersion=2.14.1
scalaVersion=2.12
scalaLibVersion=2.12.12
sparkVersion=2.4.3
glueEtlVersion=1.0.0
guavaLibVersion=29.0-jre
scalaTestVersion=3.2.0
scalaTestPlusVersion=3.2.0.0
scalaXmlVersion=1.2.0
slf4jLog4j12Version=1.7.10
diff-lib库的build.gradle
plugins {
id 'scala'
id 'java-library'
}
repositories {
maven { url 'https://repo1.maven.org/maven2/' }
mavenCentral()
maven { url 'https://aws-glue-etl-artifacts.s3.amazonaws.com/release/' }
}
dependencies {
implementation 'org.scala-lang:scala-library'
implementation 'com.amazonaws:AWSGlueETL'
implementation 'com.google.guava:guava'
}
发布于 2021-05-12 23:44:34
Glue release notes指出Scala版本需要2.11 (因为Spark 2.4.3默认使用Scala11)。一旦你为一个库使用了Scala版本,就有必要确保所有其他库都有一个匹配的版本。
您的build.gradle文件似乎缺少版本引用(或属性文件中定义版本的变量的引用)。请参阅this example,它有明确的版本号(但您也可以使用在属性文件中定义的美元符号变量)。
正如一位评论者所指出的,属性文件中的scalaLibVersion和scalaVersion不匹配。确保它们匹配,并且没有依赖项使用其他Scala版本。另外,尝试在主gradle依赖文件中使用显式版本。
https://stackoverflow.com/questions/67501902
复制相似问题