from pyspark.sql import HiveContext
from pyspark.context import SparkContext
from pyspark.conf import SparkConf


def test():
        conf = SparkConf().setAppName("My App").set("spark.io.compression.codec", "lzf")
        sc = SparkContext(conf = conf)
        hive_context = HiveContext(sc)
        hive_context.sql(''' select device["device_type"] from online.tl_hdfs_maidian_view 
        where partition_date = '20181012' and action = "page_view" 
        and params["page_name"] = "diary_detail" and params["referrer"] = "home" limit 10 ''').show(6)


if __name__ == '__main__':
        test()
