You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Justin Swett (Jira)" <ji...@apache.org> on 2019/09/03 21:01:00 UTC

[jira] [Commented] (CALCITE-3308) RelBuilder.literal with a string argument should create a character literal with appropriate character set

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

Justin Swett commented on CALCITE-3308:
---------------------------------------

FWIW, using makeCharLiteral with a NlsString and UTF-8 charset will generate the correct unicode value but the resulting SQL doesn't execute (in this example the target DB is MSSQL). 

e.g.
{quote}{{rexBuilder.makeCharLiteral(NlsString("İ","UTF-8", SqlCollation.IMPLICIT))}}
{quote}
{{generates SQL that looks like:}}
{quote}u&'N''\0130'''

specifically,

 WITH test_t AS (SELECT (cast(N'İ' as nvarchar)) AS test
 UNION ALL
 SELECT (cast(N'學校' as nvarchar)) AS test )
 SELECT
 TOP 1000
 COUNT(*) AS "test_t.count"
 FROM test_t
 WHERE (test_t.test) = u&'N''\0130'''
{quote}
 

For MSSQL I was able to override *quoteStringLiteralUnicode* and just write out the passed in value to the buffer, i.e.
{quote}{{public void quoteStringLiteralUnicode(StringBuilder buf, String val){}}

{{    buf.append(val);}}

{{}}}
{quote}
which produces sql that looks like
{quote}N'İ'

specifically, 

WITH test_t AS (SELECT (cast(N'İ' as nvarchar)) AS test
 UNION ALL
 SELECT (cast(N'學校' as nvarchar)) AS test )
SELECT
TOP 1000
 COUNT(*) AS "test_t.count"
FROM test_t
WHERE (test_t.test) = N'İ'
{quote}
 

> RelBuilder.literal with a string argument should create a character literal with appropriate character set
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-3308
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3308
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Julian Hyde
>            Priority: Major
>
> Suppose you call {{RelBuilder.literal}} with a with a string argument that contains non-ASCII characters:
> {code:java}
> RexNode e = RelBuilder.literal("☘️ my lucky charms!");{code}
>  
> The call should return a character literal with appropriate character set that can handle the contents of the string. (I'm not sure what character set should be.)



--
This message was sent by Atlassian Jira
(v8.3.2#803003)