【发布时间】:2019-04-14 12:01:24
【问题描述】:
如果我使用这个 spark sql 语句:
df = spark.sql('SELECT col_name FROM table_name')
它将返回一个火花数据框对象。如何将其转换为 rdd?有没有办法直接使用 sql 读取表但生成 rdd 而不是数据框?
提前致谢
【问题讨论】:
-
df.rdd 应该给你 RDD
-
我试过了,但没有,相反,我收到以下错误:
PicklingError: Could not serialize object: Py4JError: An error occurred while calling o60.__getstate__. Trace: py4j.Py4JException: Method __getstate__([]) does not exist at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:318) at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:326) at py4j.Gateway.invoke(Gateway.java:274) at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132) at py4j.commands.CallCommand.execute(CallCommand.java:79) -
我在这里访问了很多帖子,谈论或多或少相同的事情,但我得到了这个错误
-
stackoverflow.com/questions/29000514/… 尝试此处建议的替代方案之一
标签: python python-3.x apache-spark dataframe pyspark