以下代码已经验证为正常工作,就像我想要的那样:即将元组添加到现有序列(也是元组)
iter.map { r => // Iterator of org.apache.spark.sql.Row
r.toSeq :+ (outColName,locMap(r.getAs[String](inColName)))
}
但是我们的构建系统已启用fail on warning
,因此错误地输出上述代码:
[info] 'compiler-interface' not yet compiled for Scala 2.10.6. Compiling...
[info] Compilation completed in 24.504 s
[error] /home/../Sampling.scala:40: Adapting argument list
by creating a 2-tuple: this may not be what you want.
[error] signature: SeqLike.:+[B >: A, That](elem: B)(implicit bf: scala.collection.generic.CanBuildFrom[Repr,B,That]): That
[error] given arguments: outColName, locMap(r.getAs[String](inColName))
[error] after adaptation: SeqLike.:+((outColName, locMap(r.getAs[String](inColName))): (String, Int))
[error] r.toSeq :+ (outColName,locMap(r.getAs[String](inColName)))
[error] ^
[error] one error found
现在 - 如上所述 - 这个是我想要的。但是Travis
需要变得快乐。那么对同一个-f.e进行同义标记的正确调用是什么。这是理想的行为 - 并避免在这里发出警告?
答案 0 :(得分:1)
尝试通过显式添加方法调用和括号来帮助编译器。
iter.map { r: Row =>
r.toSeq.:+( (outColName,locMap(r.getAs[String](inColName))):Any )
}