Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

235
Visualizações
Why doesn't Hadoop respect 'spark.hadoop.fs' properties set in pyspark?

There are three properties in my spark-defaults.conf that I want to be able to set dynamically:

  • spark.driver.maxResultSize
  • spark.hadoop.fs.s3a.access.key
  • spark.hadoop.fs.s3a.secret.key

Here's my attempt to do so:

from pyspark import SparkConf
from pyspark.sql import SparkSession

conf = (SparkConf()
        .setMaster(spark_master)
        .setAppName(app_name)
        .set('spark.driver.maxResultSize', '5g')
        .set('spark.hadoop.fs.s3a.access.key', '<access>')\
        .set('spark.hadoop.fs.s3a.secret.key', '<secret>)
        )

spark = SparkSession.builder.\
    config(conf=conf).\
    getOrCreate()

print(spark.conf.get('spark.driver.maxResultSize'))
print(spark.conf.get('spark.hadoop.fs.s3a.access.key'))
print(spark.conf.get('spark.hadoop.fs.s3a.secret.key'))

spark.stop()

Here's the output I get:

5g
<access>
<secret>

However when I try to read a csv file on S3 using this configuration, I get a permissions denied error.

If I set the credentials via environment variables, I am able to read the file.

Why doesn't Hadoop respect the credentials specified this way?

Update:

I am aware of other Q&As relating to setting Hadoop properties in pyspark.

Here I am trying to record for posterity how you can be fooled into thinking that you can set them dynamically via spark.hadoop.*, since that is the name you use to set these properties in spark-defaults.conf, and since you don't get an error directly when you try to set them this way.

Many sites tell you to "set the spark.hadoop.fs.s3a.access.key property", but don't specify that this only the case if you set it statically in spark-defaults.conf and not dynamically in pyspark.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

It turns out that you can't specify Hadoop properties via:

spark.conf.set('spark.hadoop.<property>', <value>)

but you must instead use:

spark.sparkContext._jsc.hadoopConfiguration().set('<property>', <value>)

I believe you can only use spark.conf.set() for the properties listed on the Spark Configuration page.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda