大数据测试:利用spark将表中数据拆分

# 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()
    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()

 

你可能感兴趣的:(大数据测试,高级测试,physon,大数据测试基础)