[英]What type should I declare a DateTime object in a scala class constructor?
Im trying to map rows from a cassandra table to a custom class but keep getting an IllegalArgumentException for the DateTime values. 我试图将行从cassandra表映射到自定义类,但不断获得DateTime值的IllegalArgumentException。 I've tried every type I can think of and they all throw the same exception.
我已经尝试了我能想到的每种类型,它们都会抛出相同的异常。 Help would be greatly appreciated.
非常感谢帮助。 I'm a scala noob btw.
我是scala noob btw。
case class ClickData(Uuid: String, Tile: String, Latestclick: Long, OriginalTimestamp: Long, Rating: Int)
----------------------------
val data = sc.cassandraTable[ClickData]("test", "user_data")
data.foreach((i: ClickData) =>
println("CASSIE ROW: "+i)
)
table row example: 表行示例:
uuid: 4hgfyt24854grh3fg34u3re47ff, tile: blah-blah, latest_click_timestamp: 2016-08-05 16:17:53+0100, original_timestamp: 2016-08-05 16:17:53+0100, rating: 1
You can find the default Java/Scala data types in Spark here . 您可以在此处找到Spark中的默认Java / Scala数据类型。 Depending on what your data base actually contains you may want to try:
根据您的数据库实际包含的内容,您可能需要尝试:
java.sql.Date
for a DateType
column DateType
列的java.sql.Date
java.sql.Timestamp
for a TimestampType
column java.sql.Timestamp
的TimestampType
列 My parameter names did not match up with the column names, copying them out properly fixed my issue. 我的参数名称与列名称不匹配,正确复制它们修复了我的问题。 They were of type Long as well.
他们也是Long类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.