Spark Redshift with Python

后端 未结 6 1074
梦如初夏
梦如初夏 2021-01-03 10:39

I\'m trying to connect Spark with amazon Redshift but i\'m getting this error :

My code is as follow :

from pyspark.sql import SQLContext
f         


        
6条回答
  •  时光说笑
    2021-01-03 11:25

    if you are using databricks, I think you don't have to create a new sql Context because they do that for you just have to use sqlContext, try with this code:

    from pyspark.sql import SQLContext
        sc._jsc.hadoopConfiguration().set("fs.s3n.awsAccessKeyId", "YOUR_KEY_ID")
        sc._jsc.hadoopConfiguration().set("fs.s3n.awsSecretAccessKey", "YOUR_SECRET_ACCESS_KEY")
    
    df = sqlContext.read \ .......
    

    Maybe the bucket is not mounted

    dbutils.fs.mount("s3a://%s:%s@%s" % (ACCESS_KEY, ENCODED_SECRET_KEY, AWS_BUCKET_NAME), "/mnt/%s" % MOUNT_NAME)
    

提交回复
热议问题