[
https://issues.apache.org/jira/browse/CALCITE-6572?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17880972#comment-17880972
]
Claude Brisson commented on CALCITE-6572:
-----------------------------------------
Here's the log of a postgres session:
{code}
=# create temporary table t (ts timestamp);
CREATE TABLE
=# insert into t values (timestamp '2024-05-05'), (null);
INSERT 0 2
=# select to_char(ts, 'yyyy') is null from t;
?column?
----------
f
t
(2 rows)
{code}
And here's how the TO_CHAR is defined in SqlLibraryOperators.java :
{code}
/** The "TO_CHAR(timestamp, format)" function;
* converts \{@code timestamp} to string according to the given \{@code
format}.
*
* <p>(\{@code TO_CHAR} is not supported in MySQL, but it is supported in
* MariaDB, a variant of MySQL covered by \{@link SqlLibrary#MYSQL}.) */
@LibraryOperator(libraries = \{MYSQL, ORACLE, POSTGRESQL})
public static final SqlFunction TO_CHAR =
SqlBasicFunction.create("TO_CHAR",
ReturnTypes.VARCHAR,
OperandTypes.TIMESTAMP_STRING,
SqlFunctionCategory.TIMEDATE);
{code}
Obviously, the return type should be {code}ReturnTypes.VARCHAR_NULLABLE{code}.
> Calcite TO_CHAR function is incorrectly marked as returning a non-nullable
> result
> ---------------------------------------------------------------------------------
>
> Key: CALCITE-6572
> URL: https://issues.apache.org/jira/browse/CALCITE-6572
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.37.0
> Reporter: Claude Brisson
> Priority: Minor
>
> We would expect the result of TO_CHAR(<date or timestamp>, <format>) to be
> nullable, while it is not for now.
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)