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-651] Add spark prefix to all sedona spark config #1580

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/api/sql/Parameter.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ println(sedonaConf)
sparkSession.conf.set("sedona.global.index","false")
```

In addition, you can also add `spark` prefix to the parameter name, for example:

```scala
sparkSession.conf.set("spark.sedona.global.index","false")
```

However, any parameter set through `spark` prefix will be honored by Spark, which means you can set these parameters before hand via `spark-defaults.conf` or Spark on Kubernetes configuration.

If you set the same parameter through both `sedona` and `spark.sedona` prefixes, the parameter set through `sedona` prefix will override the parameter set through `spark.sedona` prefix.

## Explanation

* sedona.global.index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,38 +64,53 @@ public static SedonaConf fromActiveSession() {
}

public SedonaConf(RuntimeConfig runtimeConfig) {
this.useIndex = Boolean.parseBoolean(runtimeConfig.get("sedona.global.index", "true"));
this.indexType = IndexType.getIndexType(runtimeConfig.get("sedona.global.indextype", "rtree"));
this.useIndex = Boolean.parseBoolean(getConfigValue(runtimeConfig, "global.index", "true"));
this.indexType =
IndexType.getIndexType(getConfigValue(runtimeConfig, "global.indextype", "rtree"));
this.joinApproximateTotalCount =
Long.parseLong(runtimeConfig.get("sedona.join.approxcount", "-1"));
String[] boundaryString = runtimeConfig.get("sedona.join.boundary", "0,0,0,0").split(",");
Long.parseLong(getConfigValue(runtimeConfig, "join.approxcount", "-1"));
String[] boundaryString = getConfigValue(runtimeConfig, "join.boundary", "0,0,0,0").split(",");
this.datasetBoundary =
new Envelope(
Double.parseDouble(boundaryString[0]),
Double.parseDouble(boundaryString[1]),
Double.parseDouble(boundaryString[2]),
Double.parseDouble(boundaryString[3]));
this.joinGridType = GridType.getGridType(runtimeConfig.get("sedona.join.gridtype", "kdbtree"));
this.joinGridType =
GridType.getGridType(getConfigValue(runtimeConfig, "join.gridtype", "kdbtree"));
this.joinBuildSide =
JoinBuildSide.getBuildSide(runtimeConfig.get("sedona.join.indexbuildside", "left"));
JoinBuildSide.getBuildSide(getConfigValue(runtimeConfig, "join.indexbuildside", "left"));
this.joinSparitionDominantSide =
JoinSparitionDominantSide.getJoinSparitionDominantSide(
runtimeConfig.get("sedona.join.spatitionside", "left"));
getConfigValue(runtimeConfig, "join.spatitionside", "left"));
this.fallbackPartitionNum =
Integer.parseInt(runtimeConfig.get("sedona.join.numpartition", "-1"));
Integer.parseInt(getConfigValue(runtimeConfig, "join.numpartition", "-1"));
this.autoBroadcastJoinThreshold =
bytesFromString(
runtimeConfig.get(
"sedona.join.autoBroadcastJoinThreshold",
getConfigValue(
runtimeConfig,
"join.autoBroadcastJoinThreshold",
runtimeConfig.get("spark.sql.autoBroadcastJoinThreshold")));
this.spatialJoinOptimizationMode =
SpatialJoinOptimizationMode.getSpatialJoinOptimizationMode(
runtimeConfig.get("sedona.join.optimizationmode", "nonequi"));
getConfigValue(runtimeConfig, "join.optimizationmode", "nonequi"));

// Parameters for knn joins
this.includeTieBreakersInKNNJoins =
Boolean.parseBoolean(
runtimeConfig.get("spark.sedona.join.knn.includeTieBreakers", "false"));
Boolean.parseBoolean(getConfigValue(runtimeConfig, "join.knn.includeTieBreakers", "false"));
}

// Helper method to prioritize `sedona.*` over `spark.sedona.*`
private String getConfigValue(
RuntimeConfig runtimeConfig, String keySuffix, String defaultValue) {
String sedonaKey = "sedona." + keySuffix;
String sparkSedonaKey = "spark.sedona." + keySuffix;

if (runtimeConfig.contains(sedonaKey)) {
return runtimeConfig.get(sedonaKey, defaultValue);
} else {
return runtimeConfig.get(sparkSedonaKey, defaultValue);
}
}

public boolean getUseIndex() {
Expand Down
Loading