[ 
https://issues.apache.org/jira/browse/SPARK-32938?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17200028#comment-17200028
 ] 

Vinod KC commented on SPARK-32938:
----------------------------------

[~maseiler], 

Can you please test with this example? 
{code:java}
spark.readStream.format("kafka").option("kafka.bootstrap.servers", 
"127.0.0.1:9092").option("subscribe", "longtest").load().withColumn("key", 
conv(hex(col("key")), 16, 10).cast("bigint")).withColumn("value", 
conv(hex(col("value")), 16, 10).cast("bigint")).select("key", 
"value").writeStream.outputMode("update").format("console").start()
{code}

> Spark can not cast long value from Kafka
> ----------------------------------------
>
>                 Key: SPARK-32938
>                 URL: https://issues.apache.org/jira/browse/SPARK-32938
>             Project: Spark
>          Issue Type: Bug
>          Components: Java API, SQL, Structured Streaming
>    Affects Versions: 3.0.0
>         Environment: Debian 10 (Buster), AMD64
> Spark 3.0.0
> Kafka 2.5.0
> spark-sql-kafka-0-10_2.12
>            Reporter: Matthias Seiler
>            Priority: Major
>
> Spark seems to be unable to cast the key (or value) part from Kafka to a 
> _{color:#172b4d}long{color}_ value and throws
> {code:java}
> org.apache.spark.sql.AnalysisException: cannot resolve 'CAST(`key` AS 
> BIGINT)' due to data type mismatch: cannot cast binary to bigint;;{code}
>  
> {color:#172b4d}See this repo for further investigation:{color} 
> [https://github.com/maseiler/spark-kafka- 
> casting-bug|https://github.com/maseiler/spark-kafka-casting-bug]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to