Skip to content

Commit 034a0a8

Browse files
committed
feat: 🎸 Adds suport for custom SparkSession.Builder
✅ Closes: 41
1 parent 5983f92 commit 034a0a8

File tree

1 file changed

+9
-1
lines changed
  • kotlin-spark-api/src/main/kotlin/org/jetbrains/spark/api

1 file changed

+9
-1
lines changed

‎kotlin-spark-api/src/main/kotlin/org/jetbrains/spark/api/SparkHelper.kt

+9-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
package org.jetbrains.spark.api
2121

22+
import org.apache.spark.sql.SparkSession.Builder
2223
import org.jetbrains.spark.api.SparkLogLevel.ERROR
2324

2425
/**
@@ -31,7 +32,7 @@ import org.jetbrains.spark.api.SparkLogLevel.ERROR
3132
*/
3233
@JvmOverloads
3334
inline fun withSpark(props: Map<String, Any> = emptyMap(), master: String = "local[*]", appName: String = "Kotlin Spark Sample", logLevel: SparkLogLevel = ERROR, func: KSparkSession.() -> Unit) {
34-
SparkSession
35+
val builder = SparkSession
3536
.builder()
3637
.master(master)
3738
.appName(appName)
@@ -46,6 +47,13 @@ inline fun withSpark(props: Map<String, Any> = emptyMap(), master: String = "loc
4647
}
4748
}
4849
}
50+
withSpark(builder, logLevel, func)
51+
52+
}
53+
54+
@JvmOverloads
55+
inline fun withSpark(builder: Builder, logLevel: SparkLogLevel = ERROR, func: KSparkSession.() -> Unit) {
56+
builder
4957
.orCreate
5058
.apply {
5159
KSparkSession(this).apply {

0 commit comments

Comments
 (0)