利用spark将表中数据拆分


i
# coding:utf-8
from pyspark.sql import SparkSession

import os

if __name__ == '__main__':
os.environ['JAVA_HOME'] = 'C:\Program Files\Java\jdk1.8.0_211'
print(os.path)
spark = SparkSession \
.builder \
.appName("Python Spark SQL basic example") \
.config("spark.some.config.option", "some-value") \
.getOrCreate(http://www.my516.com)
path = "C:/Users/Administrator/Desktop/vedios.txt"
df = spark.read.csv(path, header=True)
df.createOrReplaceTempView("movies")
df = spark.sql("select * from movies lateral view explode(split(category,'#')) as type1")
df.show()
 
---------------------

posted on 2019-08-15 13:35  激流勇进1  阅读(1702)  评论(0编辑  收藏  举报