[ 
https://issues.apache.org/jira/browse/CALCITE-5884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17750707#comment-17750707
 ] 

Dan Zou edited comment on CALCITE-5884 at 8/3/23 11:30 AM:
-----------------------------------------------------------

[~mbudiu] I haven't found any restrictions on this behavior in [BigQuery 
Doc|https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#array_to_string].
 But I test it in [BigQuery|https://console.cloud.google.com/bigquery], the 
result shows that it will return null if the `null_string` is null.
{code:sql}
select array_to_string(array['1','2'], ',', NULL)
select array_to_string(array['1','2','3','4',NULL,'6'], ',', NULL);
-- both return 'NULL'
{code}


was (Author: frankzou):
[~mbudiu] I haven't found any restrictions on this behavior in [BigQuery 
Doc|https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#array_to_string].
 But I test it in [BigQuery|https://console.cloud.google.com/bigquery], the 
result shows that it will return null if the `null_string` is null.
{code:sql}
select array_to_string(array['1','2'], ',', null)

-- returns: null
{code}

> Type Inference rule for ARRAY_TO_STRING is incorrect
> ----------------------------------------------------
>
>                 Key: CALCITE-5884
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5884
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.35.0
>            Reporter: Mihai Budiu
>            Priority: Trivial
>              Labels: pull-request-available
>
> This is the current definition of the function ARRAY_TO_STRING in 
> SqlLibraryOperators:
> {code:java}
>   /** The "ARRAY_TO_STRING(array, delimiter [, nullText ])" function. */
>   @LibraryOperator(libraries = {BIG_QUERY})
>   public static final SqlFunction ARRAY_TO_STRING =
>       SqlBasicFunction.create(SqlKind.ARRAY_TO_STRING,
>           ReturnTypes.VARCHAR_NULLABLE,
>           OperandTypes.STRING_ARRAY_CHARACTER_OPTIONAL_CHARACTER);
> {code}
> So the result is nullable if any of the arguments is nullable. However, the 
> nullability of the last argument does not influence the result nullabillity: 
> a NULL value for the third optional argument will not cause a NULL value to 
> be output.



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

Reply via email to