2017-04-14 119 views
0

在Zeppelin中,我使用另一段中创建的数据框。我显示我的df变量的类型并获得:无法访问Spark数据框方法

res35: String = DataFrame 

暗示它是数据框。但是,当我尝试在DF变量使用select我得到一个错误:

<console>:62: error: value select is not a member of Object 

我必须对象转换为数据帧或东西吗?有人能告诉我我错过了什么吗? TIA!

我的代码是:

val df = z.get("wds")       
df.getClass.getSimpleName 
df.select(explode($"filtered").as("value")).groupBy("value").count.show 

这使folowwing(编辑)的输出:

df: Object = [racist: boolean, contributors: 
string, coordinates: string, ...n: Int = 20 
    res35: String = DataFrame 
    <console>:62: error: value select is not a member of Object 
        df.select(explode($"filtered").as("value")).groupBy("value").count.show 

回答

0

似乎我缺少

.asInstanceOf[DataFrame] 

import org.apache.spark.sql.DataFrame 
val df = z.get("wds").asInstanceOf[DataFrame]