You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2023/06/16 06:48:00 UTC

[jira] [Comment Edited] (CALCITE-5777) Simplify 'OperandTypes.STRING.or(OperandTypes.BINARY)' to 'OperandTypes.STRING'

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

Julian Hyde edited comment on CALCITE-5777 at 6/16/23 6:47 AM:
---------------------------------------------------------------

You can imagine how this happened. People naturally think that 'string' in SQL means 'character string' (as it does in Java).

So, fix the problem at its root. Improve the documentation of OperandTypes.STRING. Review places that use OperandTypes.STRING (and similar) and make sure that they intended to include binary strings. Check that such functions are tested with binary strings.

It may help to explicitly say 'character or binary string'. For example, the POSITION function is well documented in reference.md but in SqlPositionFunction.java nowhere does it say that the function operates on both character and binary strings.


was (Author: julianhyde):
You can imagine how this happened. People naturally think that 'string' in SQL means 'character string' (as it does in Java).

So, fix the problem at its root. Improve the documentation of OperandTypes.STRING. Review places that use OperandTypes.STRING (and similar) and make sure that they intended to include binary strings. Check that such functions are tested with binary strings.

> Simplify 'OperandTypes.STRING.or(OperandTypes.BINARY)' to 'OperandTypes.STRING'
> -------------------------------------------------------------------------------
>
>                 Key: CALCITE-5777
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5777
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Dan Zou
>            Assignee: Dan Zou
>            Priority: Major
>              Labels: pull-request-available
>
> We have used 'OperandTypes.STRING.or(OperandTypes.BINARY)' multiple times as the SqlOperandTypeChecker in 'SqlLibraryOperators'. But this is not reasonable, as the STRING family already contains BINARY family, which means we could simplify 'OperandTypes.STRING.or(OperandTypes.BINARY)' to 'OperandTypes.STRING'.
> {code:java}
>   // From 'SqlTypeName'
>   public static final List<SqlTypeName> STRING_TYPES =
>       combine(CHAR_TYPES, BINARY_TYPES);
> {code}



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