[
https://issues.apache.org/jira/browse/SPARK-31466?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Gourav Choubey updated SPARK-31466:
-----------------------------------
Summary: String/Int to VarcharType cast not supported in Spark (was:
String to VarcharType cast not supported in Spark)
> String/Int to VarcharType cast not supported in Spark
> -------------------------------------------------------
>
> Key: SPARK-31466
> URL: https://issues.apache.org/jira/browse/SPARK-31466
> Project: Spark
> Issue Type: Bug
> Components: SQL
> Affects Versions: 2.3.0
> Reporter: Gourav Choubey
> Priority: Major
>
> While casting a string column to varchar it does not do the casting at all
> and column remains string.
>
> I tried to achieve it through VarcharType as below but it errors :
> for(i<-colList){
> Df=Df.withColumn(i,Df(i).cast(VarcharType(1000)))
> }
> *org.apache.spark.sql.AnalysisException: cannot resolve 'CAST(`ColName AS
> VARCHAR(1000))' due to data type mismatch: cannot cast string to
> varchar(1000);;*
>
> *Also , I tried through selectExpr cast option but no success.*
>
> Please suggest a way to cast a string to varchar in spark. As a reading
> string column in SAS application has performance implications.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]