Skip to content

Commit

Permalink
Added ability to specify additional Spark config (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
edfreeman authored Nov 18, 2024
1 parent 296f651 commit 2f01187
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class LocalSparkSessionConfig():
Azure CLI credentials.
enable_spark_ui (bool, optional): Whether to enable the Spark UI. Defaults to True. It can be useful to turn
the UI off for unit tests to avoid port binding issues.
additional_spark_config (dict, optional): Additional Spark configuration to set. Defaults to an empty dict.
"""
workload_name: str
storage_configuration: StorageConfiguration = LocalFileSystemStorageConfiguration(os.path.join(CWD, "data"))
Expand All @@ -42,6 +43,7 @@ class LocalSparkSessionConfig():
enable_az_cli_auth: bool = False
enable_spark_ui: bool = True
extra_packages: list = field(default_factory=lambda: [])
additional_spark_config: dict = field(default_factory=lambda: {})


@dataclass
Expand Down Expand Up @@ -100,6 +102,10 @@ def create_spark_session(self) -> SparkSession:
.config("spark.driver.extraJavaOptions", f"-Dderby.system.home={hive_metastore_dir}") \
.enableHiveSupport()

if self.config.additional_spark_config:
for k, v in self.config.additional_spark_config.items():
builder = builder.config(k, v)

spark = configure_spark_with_delta_pip(builder, extra_packages=extra_packages).getOrCreate()

if self.config.enable_az_cli_auth:
Expand Down

0 comments on commit 2f01187

Please sign in to comment.