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

Julian Hyde commented on CALCITE-111:
-------------------------------------

I don't think the MySQL {{CONVERT}} function is based on the SQL standard. In 
fact it's more similar to {{CAST}}. I think it should be out of scope for this 
discussion. (We can discuss a new function - let's call it {{MYSQL_CONVERT}} - 
in another thread, if you wish.)

[Postgres CONVERT|https://postgrespro.com/docs/postgresql/9.5/functions-string] 
seems to comply with the standard; its {{TRANSLATE}} is based on Oracle's 
{{TRANSLATE}}, which is unrelated (Calcite calls it {{TRANSLATE3}}). 

In the standard, {{CONVERT}} and {{TRANSLATE}} are related (they both deal with 
character sets) but are not identical:
* {{CONVERT}} has arguments {{(string bytea, src_encoding name, dest_encoding 
name)}}, for example {{convert('text_in_utf8', 'UTF8', 'LATIN1')}} 
* I haven't checked the spec but I think {{TRANSLATE}} has arguments {{(string 
bytea, translation name)}}.

I have no strong opinion whether you assign one SqlKind or two. I think the 
first step is to write a few use cases (SQL expressions and what the result 
should be). Can you write those here? Then create a test based on those cases, 
and get it to pass.

> Support CONVERT function, for changing character sets
> -----------------------------------------------------
>
>                 Key: CALCITE-111
>                 URL: https://issues.apache.org/jira/browse/CALCITE-111
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: GitHub Import
>            Assignee: ZheHu
>            Priority: Major
>              Labels: github-import
>
> Support the CONVERT function, to convert strings from one character set to 
> another.
> CONVERT is defined in SQL:2011 as a feature called <character 
> transliteration>. Here is an example:
> ```sql
> SELECT * FROM emp WHERE CONVERT(name USING UTF16) = u&'\82f1\56fd'
> ```
> The <a 
> href="http://dev.mysql.com/doc/refman/5.0/en/charset-convert.html";>MySQL 
> site</a> has other examples.
> ---------------- Imported from GitHub ----------------
> Url: https://github.com/julianhyde/optiq/issues/111
> Created by: [julianhyde|https://github.com/julianhyde]
> Labels: enhancement, 
> Created at: Tue Jan 14 03:40:53 CET 2014
> State: open



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to