2014-11-23 34 views
0

我想用scala case类来映射Cassandra表。Cassandra表中SparkStax中的Spark映射

我的一些列名恰好是scala中的保留关键字。有没有简单的方法来映射它们?

如:

Cassandra Table 
Create Table cars (
id_uuid uuid, 
new boolean, 
type text, 
PRIMARY KEY ((id_uuid)) 
) 

// This declaration will fail as "new" and "type" are reserved keywords 
scala> case class Cars (idUuid : String, new : Boolean, type: String) 

回答

1

试试这个:

case class Cars (idUuid:String, `new`:Boolean, `type`:String) 
+0

如果可能的话,尽量避免使用卡桑德拉关键字和大小写混合的名称为列,如果你打算使用SparkSQL。它以时髦的方式失败。 [如果你不需要在开发中心查询报价,你的列名就可以。] – ashic 2014-11-24 13:53:36

+0

甜蜜,这个工作。谢谢 – mob 2014-11-24 15:08:10