You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Apache Spark (Jira)" <ji...@apache.org> on 2021/07/12 04:13:00 UTC

[jira] [Assigned] (SPARK-36076) [SQL] ArrayIndexOutOfBounds in CAST string to timestamp

     [ https://issues.apache.org/jira/browse/SPARK-36076?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Apache Spark reassigned SPARK-36076:
------------------------------------

    Assignee:     (was: Apache Spark)

> [SQL] ArrayIndexOutOfBounds in CAST string to timestamp
> -------------------------------------------------------
>
>                 Key: SPARK-36076
>                 URL: https://issues.apache.org/jira/browse/SPARK-36076
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 3.1.1
>            Reporter: Andy Grove
>            Priority: Major
>
> I discovered this bug during some fuzz testing.
> {code:java}
>       ____              __
>      / __/__  ___ _____/ /__
>     _\ \/ _ \/ _ `/ __/  '_/
>    /___/ .__/\_,_/_/ /_/\_\   version 3.1.1
>       /_/
>          
> Using Scala version 2.12.10 (OpenJDK 64-Bit Server VM, Java 1.8.0_282)
> Type in expressions to have them evaluated.
> Type :help for more information.scala> 
> scala> import org.apache.spark.sql.types.DataTypes
> scala> val df = Seq(":8:434421+ 98:38").toDF("c0")
> df: org.apache.spark.sql.DataFrame = [c0: string]
> scala> val df2 = df.withColumn("c1", col("c0").cast(DataTypes.TimestampType))
> df2: org.apache.spark.sql.DataFrame = [c0: string, c1: timestamp]
> scala> df2.show
> java.lang.ArrayIndexOutOfBoundsException: 9
>   at org.apache.spark.sql.catalyst.util.DateTimeUtils$.stringToTimestamp(DateTimeUtils.scala:328)
>   at org.apache.spark.sql.catalyst.expressions.CastBase.$anonfun$castToTimestamp$2(Cast.scala:455)
>   at org.apache.spark.sql.catalyst.expressions.CastBase.buildCast(Cast.scala:295)
>   at org.apache.spark.sql.catalyst.expressions.CastBase.$anonfun$castToTimestamp$1(Cast.scala:451)
>   at org.apache.spark.sql.catalyst.expressions.CastBase.nullSafeEval(Cast.scala:840)
>   at org.apache.spark.sql.catalyst.expressions.UnaryExpression.eval(Expression.scala:476)
>  {code}



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

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