-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added spark connect example which does not yet work with kotlin-spark…
…-api
- Loading branch information
1 parent
eae0196
commit 22fa5ae
Showing
9 changed files
with
98 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
kotlin-spark-api/src/test/kotlin/org/jetbrains/kotlinx/spark/api/RddTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
|
||
plugins { | ||
// Needs to be installed in the local maven repository or have the bootstrap jar on the classpath | ||
id("org.jetbrains.kotlinx.spark.api") | ||
kotlin("jvm") | ||
application | ||
} | ||
|
||
// run with `./gradlew run` | ||
application { | ||
mainClass = "org.jetbrains.kotlinx.spark.examples.MainKt" | ||
|
||
// workaround for java 17 | ||
applicationDefaultJvmArgs = listOf("--add-opens", "java.base/java.nio=ALL-UNNAMED") | ||
} | ||
|
||
kotlinSparkApi { | ||
enabled = true | ||
sparkifyAnnotationFqNames = listOf("org.jetbrains.kotlinx.spark.api.plugin.annotations.Sparkify") | ||
} | ||
|
||
group = Versions.groupID | ||
version = Versions.project | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
Projects { | ||
implementation( | ||
// TODO kotlinSparkApi, | ||
) | ||
} | ||
|
||
Dependencies { | ||
|
||
// IMPORTANT! | ||
compileOnly(sparkSqlApi) | ||
implementation(sparkConnectClient) | ||
} | ||
} | ||
|
||
// spark-connect seems to work well with java 17 as client and java 1.8 as server | ||
// also set gradle and your project sdk to java 17 | ||
kotlin { | ||
jvmToolchain { | ||
languageVersion = JavaLanguageVersion.of(17) | ||
} | ||
compilerOptions { | ||
jvmTarget = JvmTarget.JVM_17 | ||
} | ||
} | ||
|
||
tasks.withType<JavaCompile> { | ||
sourceCompatibility = JavaVersion.VERSION_17.toString() | ||
targetCompatibility = JavaVersion.VERSION_17.toString() | ||
} |
27 changes: 27 additions & 0 deletions
27
spark-connect-examples/src/main/kotlin/org/jetbrains/kotlinx/spark/examples/Main.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.jetbrains.kotlinx.spark.examples | ||
|
||
import org.apache.spark.sql.SparkSession | ||
import org.apache.spark.sql.connect.client.REPLClassDirMonitor | ||
|
||
// run with `./gradlew run` or set VM options: "--add-opens=java.base/java.nio=ALL-UNNAMED" in the IDE | ||
fun main() { | ||
val spark = | ||
SparkSession | ||
.builder() | ||
.remote("sc://localhost") | ||
.create() | ||
|
||
val classFinder = REPLClassDirMonitor("/mnt/data/Projects/kotlin-spark-api/spark-connect-examples/build/classes") | ||
spark.registerClassFinder(classFinder) | ||
spark.addArtifact("/mnt/data/Projects/kotlin-spark-api/spark-connect-examples/build/libs/spark-connect-examples-2.0.0-SNAPSHOT.jar") | ||
|
||
spark.sql("select 1").show() | ||
|
||
spark.stop() | ||
} | ||
|
||
//@Sparkify | ||
//data class Person( | ||
// val name: String, | ||
// val age: Int, | ||
//) |