传递给方法的RDD上的saveToCassandra因scala.ScalaReflectionException而失败:<none>不是一个术语

时间:2017-03-10 01:08:30

标签: scala apache-spark datastax datastax-enterprise spark-cassandra-connector

使用Spark 2.1.0和spark-cassandra-connector 2.0.0-RC1-s_2.11。 调用rdd.saveToCassandra("keyspace", "table", SomeColumns("A", "B"))在与其他转换相同的函数内完成时工作正常。但是,在同一对象上定义方法如下:

 def saveToCassandra(rdd: RDD[_], keyspace: String, table: String, columns: SomeColumns) = {
     rdd.saveToCassandra(keyspace, table, columns)
 }

使用saveToCassandra(rdd, "keyspace", "table", SomeColumns("A", "B"))调用它失败了:

Exception in thread "main" scala.ScalaReflectionException: <none> is not a term
at scala.reflect.api.Symbols$SymbolApi$class.asTerm(Symbols.scala:199)
at scala.reflect.internal.Symbols$SymbolContextApiImpl.asTerm(Symbols.scala:84)
at com.datastax.spark.connector.util.Reflect$.methodSymbol(Reflect.scala:12)
at com.datastax.spark.connector.util.ReflectionUtil$.constructorParams(ReflectionUtil.scala:63)
at com.datastax.spark.connector.mapper.DefaultColumnMapper.<init>(DefaultColumnMapper.scala:45)
at com.datastax.spark.connector.mapper.LowPriorityColumnMapper$class.defaultColumnMapper(ColumnMapper.scala:51)
at com.datastax.spark.connector.mapper.ColumnMapper$.defaultColumnMapper(ColumnMapper.scala:55)

1 个答案:

答案 0 :(得分:0)

使用RDD的类型标记定义辅助方法,例如<ListView ................ .................... android:background="#FFFFFF" /> 代替Ok, try this one. SELECT S1.name, ((S1.games*S1.score)+(S2.games*S2.score)+(S3.games*S3.score)+(S4.games*S4.score)) / ((S1.games)+(S2.games)+(S3.games)+(S4.games)) as TOTAL FROM (SELECT S1.name as name, S1.games as S1Games, S1.score as S1Score, S2.games as S2Games, S2.score as S2Score, S3.games as S3Games, S3.score as S3Score, S4.games as S4Games, S4.score as S4Score FROM Season1 as S1 JOIN Season2 as S2 ON S1.name = S2.name JOIN Season3 as S3 ON S1.name = S3.name JOIN Season4 as S3 ON s1.name = S4.name) GROUP BY S1.name 来解决问题。我想这与数据共享连接器中的反射代码以及它从编译时类型中推断出运行时类型的方式有关。显然将下划线作为任何类型删除类型信息以进行反射。我对Scala不熟悉并且不知道Scala中的反射如何工作以及是否需要这种行为。