python pyspark-sql-hive-context.py

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python pyspark-sql-hive-context.py相关的知识,希望对你有一定的参考价值。

# from pyspark.sql import HiveContext
# sqlContext = new HiveContext(sc);
sqlContext.setConf("spark.sql.shuffle.partitions", "2")
sqlContext.sql("use sparkdemo")

sql = """select o.order_date, sum(oi.order_item_subtotal) daily_revenue
        from orders o join order_items oi 
        on o.order_id = oi.order_item_order_id
        where o.order_status = 'COMPLETE' 
        group by o.order_date 
        order by o.order_date"""

sqlContext.sql(sql).show()

sqlContext.sql("create table daily_revenue(order_date string, daily_revenue float)")

i = "insert into daily_revenue " + sql
sqlContext.sql(i)

sqlContext.sql("select * from daily_revenue").show()

以上是关于python pyspark-sql-hive-context.py的主要内容,如果未能解决你的问题,请参考以下文章

Python代写,Python作业代写,代写Python,代做Python

Python开发

Python,python,python

Python 介绍

Python学习之认识python

python初识