Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SEDONA-568] Refactor TestBaseScala to allow customizable Spark configurations #1455

Merged

Conversation

zhangfengcdt
Copy link
Collaborator

  • Added default Spark configurations in TestBaseScala trait.
  • Provided a method defaultSparkConfig for default configurations.
  • Allowed subclasses to override sparkConfig to add or modify Spark configurations.
  • Updated initialization of Spark session and Spark context to use the provided configurations.
  • Included comments to explain how to override configurations in subclasses.
  • Ensured that default configurations are preserved if not overridden by subclasses.

Did you read the Contributor Guide?

Is this PR related to a JIRA ticket?

What changes were proposed in this PR?

  • Added default Spark configurations in TestBaseScala trait.
  • Provided a method defaultSparkConfig for default configurations.
  • Allowed subclasses to override sparkConfig to add or modify Spark configurations.
  • Updated initialization of Spark session and Spark context to use the provided configurations.
  • Included comments to explain how to override configurations in subclasses.
  • Ensured that default configurations are preserved if not overridden by subclasses.

After this change, user can either use

  • Default Configurations: Provided in defaultSparkConfig.
  • Overriding Configurations: Subclasses can override sparkConfig and merge additional configurations with the default ones using the ++ operator, for example:
class CustomTest extends TestBaseScala {
  // Override sparkConfig to provide additional configurations
  override def sparkConfig: Map[String, String] = defaultSparkConfig ++ Map(
    "spark.sql.warehouse.dir" -> "/custom/warehouse/location",
    "spark.some.config.option" -> "some-value"
  )

  describe("CustomTest") {
    it("should use custom Spark configuration") {
      assert(sparkSession.conf.get("spark.some.config.option") == "some-value")
    }

    it("should access Spark context") {
      assert(sc != null)
    }
  }
}

How was this patch tested?

All existing unit tests should all pass without any impact.

Did this PR include necessary documentation updates?

  • No, this PR does not affect any public API so no need to change the documentation.

…gurations

- Added default Spark configurations in `TestBaseScala` trait.
- Provided a method `defaultSparkConfig` for default configurations.
- Allowed subclasses to override `sparkConfig` to add or modify Spark configurations.
- Updated initialization of Spark session and Spark context to use the provided configurations.
- Included comments to explain how to override configurations in subclasses.
- Ensured that default configurations are preserved if not overridden by subclasses.
@jiayuasu jiayuasu added this to the sedona-1.6.1 milestone Jun 7, 2024
@jiayuasu jiayuasu merged commit 94cd82b into apache:master Jun 7, 2024
50 checks passed
Kontinuation pushed a commit to Kontinuation/sedona that referenced this pull request Oct 11, 2024
…le Spark configurations (apache#214)

* [SEDONA-568] Refactor TestBaseScala to allow customizable Spark configurations (apache#1455)

- Added default Spark configurations in `TestBaseScala` trait.
- Provided a method `defaultSparkConfig` for default configurations.
- Allowed subclasses to override `sparkConfig` to add or modify Spark configurations.
- Updated initialization of Spark session and Spark context to use the provided configurations.
- Included comments to explain how to override configurations in subclasses.
- Ensured that default configurations are preserved if not overridden by subclasses.

* Move wherobots specific spark config to pythonUdfTest

* add usage comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants