天天看點

[Spark][Python][DataFrame][SQL]Spark對DataFrame直接執行SQL處理的例子

[Spark][Python][DataFrame][SQL]Spark對DataFrame直接執行SQL處理的例子

$cat people.json

$ hdfs dfs -put people.json

$pyspark

sqlContext = HiveContext(sc)

peopleDF = sqlContext.read.json("people.json")

peopleDF.registerTempTable("people")

tmpDF=sqlContext.sql(""" select * FROM people WHERE name like "A%" """)

tmpDF.limit(3).show()