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

Apache Spark reassigned SPARK-41452:
------------------------------------

    Assignee: Apache Spark

> to_char throws NullPointerException when format is null
> -------------------------------------------------------
>
>                 Key: SPARK-41452
>                 URL: https://issues.apache.org/jira/browse/SPARK-41452
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 3.4.0
>            Reporter: Bruce Robbins
>            Assignee: Apache Spark
>            Priority: Major
>
> Example:
> {noformat}
> spark-sql> select to_char(454, null);
> [INTERNAL_ERROR] The Spark SQL phase analysis failed with an internal error. 
> You hit a bug in Spark or the Spark plugins you use. Please, report this bug 
> to the corresponding communities or vendors, and provide the full stack trace.
> org.apache.spark.SparkException: [INTERNAL_ERROR] The Spark SQL phase 
> analysis failed with an internal error. You hit a bug in Spark or the Spark 
> plugins you use. Please, report this bug to the corresponding communities or 
> vendors, and provide the full stack trace.
> ...
> Caused by: java.lang.NullPointerException
>       at 
> org.apache.spark.sql.catalyst.expressions.ToCharacter.numberFormat$lzycompute(numberFormatExpressions.scala:227)
>       at 
> org.apache.spark.sql.catalyst.expressions.ToCharacter.numberFormat(numberFormatExpressions.scala:227)
>       at 
> org.apache.spark.sql.catalyst.expressions.ToCharacter.numberFormatter$lzycompute(numberFormatExpressions.scala:228)
>       at 
> org.apache.spark.sql.catalyst.expressions.ToCharacter.numberFormatter(numberFormatExpressions.scala:228)
>       at 
> org.apache.spark.sql.catalyst.expressions.ToCharacter.checkInputDataTypes(numberFormatExpressions.scala:236)
> {noformat}
> Compare to {{to_binary}}:
> {noformat}
> spark-sql> SELECT to_binary('abc', null);
> NULL
> Time taken: 3.097 seconds, Fetched 1 row(s)
> spark-sql>
> {noformat}
> Also compare to {{to_char}} in PostgreSQL 14.6:
> {noformat}
> select to_char(454, null) is null as to_char_is_null;
>  to_char_is_null 
> -----------------
>  t
> (1 row)
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to