I've been working on writing some spark to write cassandra data to kafka. I chose to use Kotlin for giggles.
When upgrading to cassandra connector to 3.0.0, the kotlin compiler all of a sudden can no longer handle some of the spark functions (e.g. struct, alias, etc.).
Luckily I'm not using any of the classes from the connector and can set the scope to runtime and that works for me.
Should this be a bug? I had no issues with earlier versions of the connector, thankfully this workaround unblocks me, but perhaps this could be an issue for someone else.
Gradle:
compile("com.datastax.spark:spark-cassandra-connector_2.12:3.0.0") //does not work
runtime("com.datastax.spark:spark-cassandra-connector_2.12:3.0.0") //works
import org.apache.spark.sql.functions.*
query.select(
to_json(col("id")).alias("key"),
to_json(struct(col("*")).alias("value"), // fails to compile
.write()
.format("kafka")
.option("kafka.bootstrap.servers", kafka.bootstrapServers.joinToString())
.option("topic", topicName)
.save()
e: org.jetbrains.kotlin.util.KotlinFrontEndException: Exception while analyzing expression