https://kotlinlang.org logo
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
benchmarks
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
confetti
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
lincheck
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by
Title
i

ita

06/10/2022, 2:30 PM
Hello, everyone. Quick help needed here. Recently I upgraded my AWS EMR instance to emr-6.6.0 and my jobs started failing. It is most likely some Kotlin Spark API incompatibility with Spark 3.2.0. More in the thread.
EMR 6.6.0 uses Spark 3.2.0 so I started getting:
User class threw exception: java.lang.NoSuchMethodError: org.apache.spark.sql.catalyst.expressions.objects.Invoke$.apply$default$5()Z
at org.apache.spark.sql.KotlinReflection$.$anonfun$serializerFor$16(KotlinReflection.scala:754)
at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:286)
at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:198)
at scala.collection.TraversableLike.map(TraversableLike.scala:286)
at scala.collection.TraversableLike.map$(TraversableLike.scala:279)
at scala.collection.mutable.ArrayOps$ofRef.map(ArrayOps.scala:198)
at org.apache.spark.sql.KotlinReflection$.$anonfun$serializerFor$1(KotlinReflection.scala:748)
at scala.reflect.internal.tpe.TypeConstraints$UndoLog.undo(TypeConstraints.scala:73)
at org.apache.spark.sql.KotlinReflection.cleanUpReflectionObjects(KotlinReflection.scala:1012)
at org.apache.spark.sql.KotlinReflection.cleanUpReflectionObjects$(KotlinReflection.scala:1011)
at org.apache.spark.sql.KotlinReflection$.cleanUpReflectionObjects(KotlinReflection.scala:47)
at org.apache.spark.sql.KotlinReflection$.serializerFor(KotlinReflection.scala:591)
at org.apache.spark.sql.KotlinReflection$.serializerFor(KotlinReflection.scala:578)
at org.apache.spark.sql.KotlinReflection.serializerFor(KotlinReflection.scala)
at org.jetbrains.kotlinx.spark.api.ApiV1Kt.kotlinClassEncoder(ApiV1.kt:180)
at org.jetbrains.kotlinx.spark.api.ApiV1Kt.generateEncoder(ApiV1.kt:167)
at movoto.leadsync.jobs.ExtractJob.<init>(ExtractJob.kt:218)
at movoto.leadsync.ExtractCommand.run(SparkJobMain.kt:104)
at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:198)
at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:211)
at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:18)
at com.github.ajalt.clikt.core.CliktCommand.parse(CliktCommand.kt:395)
at com.github.ajalt.clikt.core.CliktCommand.parse$default(CliktCommand.kt:392)
at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:410)
at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:435)
at movoto.leadsync.SparkJobMainKt.main(SparkJobMain.kt:189)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.spark.deploy.yarn.ApplicationMaster$$anon$2.run(ApplicationMaster.scala:740)
Unmanaged Application:
Here it says there is no support for Spark 3.2.0 https://github.com/Kotlin/kotlin-spark-api#supported-versions-of-apache-spark Is there any tweak I can do in order to make it work, rather in my Kotlin/Spark incantations or adding to my cluster? By now we rolled back our EMR instance to 6.5.0.
i

Ilya Muradyan

06/10/2022, 2:42 PM
@Jolan Rensen [JetBrains]
j

Jolan Rensen [JetBrains]

06/10/2022, 2:45 PM
We support the latest supported releases from Apache: https://spark.apache.org/downloads.html, I assumed that 3.2.0 would be compatible with 3.2.1 at least...
you are running Scala 2.12?
👀 1
i

ita

06/10/2022, 2:52 PM
specifically signature of a spark method we are having issues with
Yes Scala 2.12
2.12.10
p

Pasha Finkelshteyn

06/10/2022, 2:58 PM
And which version of Kotlin API for Apache Spark do you use?
If you have reproducible example — we would test it. There can be several resons for incompatibility starting from internal incompatibility of Spark itself to inconsistency between compile and provided dependencies in your build and in EMR
👀 1
i

ita

06/10/2022, 3:01 PM
that was
kotlin-spark-api-3.0:1.0.2
but local testing produced the same issue w/
kotlin-spark-api-3.2:1.1.0
on Spark 3.2.0 but not Spark 3.2.1
p

Pasha Finkelshteyn

06/10/2022, 3:02 PM
So it works with 3.2.1, but doen't work with 3.2.0?
i

ita

06/10/2022, 3:02 PM
Correct
p

Pasha Finkelshteyn

06/10/2022, 3:03 PM
Looks like they have "fixed" something 🙂 But we still would prefer to have a reproducer. If you can't share it publicly — feel free to contact me or @Jolan Rensen [JetBrains] in DM.
j

Jolan Rensen [JetBrains]

06/10/2022, 3:07 PM
yes please 🙂
debugging that part of the code is hard, so having something we can test would be awesome
i

ita

06/10/2022, 3:12 PM
I am working on this. I’ll make as simple as possible… Gimme a moment, please
p

Pasha Finkelshteyn

06/10/2022, 3:13 PM
Thank you very much!
j

Jolan Rensen [JetBrains]

06/10/2022, 3:13 PM
no haste 🙂 I don't think I have time before the weekend anyways, but I'll definitely check it out on Monday
i

ita

06/10/2022, 3:30 PM
That’s good to hear actually. We reverted the change to emr-6.5.0 and things are back to business. I also am in a hurry today, so push it forward a day or two.
Actually here is a simple reproducible piece of code:
import io.kotest.core.spec.style.FunSpec
import org.apache.spark.sql.Dataset
import org.apache.spark.sql.SparkSession
import org.jetbrains.kotlinx.spark.api.dsOf
import <http://org.jetbrains.kotlinx.spark.api.to|org.jetbrains.kotlinx.spark.api.to>

data class DowncastType(
    val intType: Int? = null,
)

class SparkDowncastTest : FunSpec({
    val spark = SparkSession.builder().master("local[*]").orCreate

    afterSpec {
        spark.stop()
    }

    test("test spark downcasting") {
        val dataset = spark.dsOf("intType" to 1)

        val casted: Dataset<DowncastType> = <http://dataset.to|dataset.to>()
    }
})
j

Jolan Rensen [JetBrains]

06/13/2022, 9:44 AM
What are you trying to achieve with this example? Running it on 3.2.1 also gives:
Exception in thread "main" org.apache.spark.sql.AnalysisException: cannot resolve 'intType' given input columns: [first, second]
Which makes sense, since you are trying to implicitly convert a
Dataset<Pair<String, Int>>
to
Dataset<DowncastType>
which is a completely different class
Or is it just to reproduce the error, because on 3.2.0 I can indeed reproduce it with this example 🙂
I'll use
data class Type(val intType: Int)
...
dsOf(Type(intType = 1))
...
instead 🙂
Okay, I've narrowed down the bug to the exact place where it's called in the code. We use an adapted version of a Spark file (KotlinReflection.scala instead of ScalaReflection.scala) to enable support for Kotlin data classes and whatnot. However, since this is essentially a replacement for the actual file, the Spark version must match exactly as well... We're still debating how to handle this in the future. I'll try to keep you up to date 🙂 For now, however, you can either wait until EMR updates to 3.2.1, or you can build the spark-3.2 branch adapted to 3.2.0 from source.
i

ita

06/14/2022, 4:39 PM
Thank you so much @Jolan Rensen [JetBrains] and @Pasha Finkelshteyn. You are incredible. I’ll take a look on how to build that branch.