📜  返回表示给定查询结果的 DataFrame - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:46.244000             🧑  作者: Mango

代码示例1
# Returns a DataFrame representing the result of the given query

df.createOrReplaceTempView("table1")
df2 = spark.sql("SELECT field1 AS f1, field2 as f2 from table1")
df2.collect()
# [Row(f1=1, f2='row1'), Row(f1=2, f2='row2'), Row(f1=3, f2='row3')]