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 2022/12/08 21:32:00 UTC

[jira] [Assigned] (SPARK-41452) to_char throws NullPointerException when format is null

     [ 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: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org