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

Yu Xu commented on CALCITE-7063:
--------------------------------

According to the documentation, the concat function should be able to use both 
string and bytestring, so the previous definition is wrong and should be 
directly replaced with Object... instead of String... 
I made some modifications to adapt to the capabilities described in the 
documentation, related pr(https://github.com/apache/calcite/pull/4431), and 
also provided the following actual MySQL test case:

 
{code:java}
mysql> select concat('a',binary('b'));
+--------------------------------------------------+
| concat('a',binary('b'))                          |
+--------------------------------------------------+
| 0x6162                                           |
+--------------------------------------------------+
1 row in set, 1 warning (0.00 sec)
{code}
{code:java}
mysql> select concat('a',binary('b'),null);
+------------------------------------------------------------+
| concat('a',binary('b'),null)                               |
+------------------------------------------------------------+
| NULL                                                       |
+------------------------------------------------------------+
1 row in set, 1 warning (0.00 sec)
 {code}
{code:java}
mysql> select concat('a','b');
+-----------------+
| concat('a','b') |
+-----------------+
| ab              |
+-----------------+
1 row in set (0.00 sec) {code}
According to the documentation, if there is a binary in the parameter, the 
concatenation result of the binary string is returned, otherwise the 
concatenation result of the string is returned.

 

> Result type inferred for CONCAT_FUNCTION is incorrect for BINARY arguments
> --------------------------------------------------------------------------
>
>                 Key: CALCITE-7063
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7063
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.40.0
>            Reporter: Mihai Budiu
>            Assignee: Yu Xu
>            Priority: Minor
>
> Calcite supports the MySQL CONCAT function.
> This function can have either VAR/CHAR or VAR/BINARY arguments. This holds 
> true for the Calcite implementation. However, the Calcite implementation 
> always infers a VAR/CHAR return type. 
> Moreover, there are no tests for BINARY arguments, so I suspect that this has 
> not been considered. Either the function should reject such arguments, or it 
> should correctly infer the return type.
> Note that OperandTypes.STRING for the operandTypeChecker can be misleading, 
> since the STRING type family includes BINARY.
>  



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

Reply via email to