How to execute .sql file in spark using python

前端 未结 3 1290
广开言路
广开言路 2021-01-18 07:25
from pyspark import SparkConf, SparkContext
from pyspark.sql import SQLContext

conf = SparkConf().setAppName(\"Test\").set(\"spark.driver.memory\", \"1g\")
sc = Spa         


        
3条回答
  •  遥遥无期
    2021-01-18 07:44

    SqlContext.sql expects a valid SQL query not a path to the file. Try this:

    with open("/home/ubuntu/workload/queryXX.sql") as fr:
       query = fr.read()
    results = sqlContext.sql(query)
    

提交回复
热议问题