FlatMap 可遍历错误
FlatMap Traversable Ones Error
我有以下代码:
//TABLE FROM HIve
val df = hiveContext.sql("select * from test_table where date ='20160721' LIMIT 300")
//ERROR ON THE LINE BELOW
val row = df.flatMap(row => ((row.get(0), row.get(1), row.get(2)), 1))
我在上面的代码中得到这个错误:
Type mismatch, expected: (Row) => Traversable[NotInferedU], actual : (Row) => ((Any, Any, Any), Int)
谁能检查一下我的 flatMap 函数有什么问题。我无法理解此错误的含义。
您可能应该改用 map
。 ((row.get(0), row.get(1), row.get(2)), 1)
不是错误消息所述的 Traversable
。
我有以下代码:
//TABLE FROM HIve
val df = hiveContext.sql("select * from test_table where date ='20160721' LIMIT 300")
//ERROR ON THE LINE BELOW
val row = df.flatMap(row => ((row.get(0), row.get(1), row.get(2)), 1))
我在上面的代码中得到这个错误:
Type mismatch, expected: (Row) => Traversable[NotInferedU], actual : (Row) => ((Any, Any, Any), Int)
谁能检查一下我的 flatMap 函数有什么问题。我无法理解此错误的含义。
您可能应该改用 map
。 ((row.get(0), row.get(1), row.get(2)), 1)
不是错误消息所述的 Traversable
。