Help Center> Data Lake Insight> FAQs> Problems Related to Spark Jobs> How Do I Set the AK/SK for a Spark Queue to Operate an OBS Table?

How Do I Set the AK/SK for a Spark Queue to Operate an OBS Table?

  • When creating the SparkContext, do as follows:
    val sc: SparkContext = new SparkContext()
    sc.hadoopConfiguration.set("fs.obs.access.key", ak)
    sc.hadoopConfiguration.set("fs.obs.secret.key", sk)
  • When creating the SparkSession, do as follows:
    val sparkSession: SparkSession = SparkSession
          .builder()
          .config("spark.hadoop.fs.obs.access.key", ak)
          .config("spark.hadoop.fs.obs.secret.key", sk)
          .enableHiveSupport()
          .getOrCreate()

The temporary AK/SK is recommended. For details, see Obtaining a Temporary Access Key and Security Token in the Identity and Access Management API Reference.

For security purposes, you are advised not to include the AK and SK information in the OBS path. In addition, if a table is created in the OBS directory, the OBS path specified by the Path field cannot contain the AK and SK information.