[
https://issues.apache.org/jira/browse/CALCITE-6700?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Mihai Budiu resolved CALCITE-6700.
----------------------------------
Fix Version/s: 1.39.0
Resolution: Fixed
Fixed in
https://github.com/apache/calcite/commit/ea51d91d7d0849121eaf29298994054e3c4ae9a6
Thank you for the contribution [~duanzhengqiang]
Thank you for the reviews, reviewers.
> MySQL BIT_COUNT function should return result when parameter is Boolean,
> String, Date, Time and Timestamp types
> ---------------------------------------------------------------------------------------------------------------
>
> Key: CALCITE-6700
> URL: https://issues.apache.org/jira/browse/CALCITE-6700
> Project: Calcite
> Issue Type: Bug
> Affects Versions: 1.38.0
> Reporter: Zhengqiang Duan
> Assignee: Zhengqiang Duan
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.39.0
>
>
> In CALCITE-3697, Caclite already supports MySQL BIT_COUNT by reusing the
> standard BITCOUNT function logic, but when I tested more MySQL data types,
> the Calcite validator would report errors because the standard BITCOUNT
> function does not support these types.
> For example, when I execute the following query, the Calcite validator throws
> the exception Cannot apply 'BIT_COUNT' to arguments of type
> 'BIT_COUNT(<BOOLEAN>)'. Supported form(s): 'BIT_COUNT(<NUMERIC>)'.
> {code:java}
> SELECT bit_count(123456), bit_count('123456'), bit_count('abcdefg'),
> BIT_COUNT('abcdef1234'), bit_count(''), bit_count(1 + 1), bit_count(true)
> {code}
> Executed via MySQL, they all return correct results.
> {code:java}
> mysql> SELECT bit_count(123456), bit_count('123456'), bit_count('abcdefg'),
> BIT_COUNT('abcdef1234'), bit_count(''), bit_count(1 + 1), bit_count(true) ;
> +-------------------+---------------------+----------------------+-------------------------+---------------+------------------+-----------------+
> | bit_count(123456) | bit_count('123456') | bit_count('abcdefg') |
> BIT_COUNT('abcdef1234') | bit_count('') | bit_count(1 + 1) | bit_count(true) |
> +-------------------+---------------------+----------------------+-------------------------+---------------+------------------+-----------------+
> | 6 | 6 | 0 |
> 0 | 0 | 1 | 1 |
> +-------------------+---------------------+----------------------+-------------------------+---------------+------------------+-----------------+
> 1 row in set, 3 warnings (0.00 sec) {code}
> In addition to the sample SQL above, the MySQL BIT_COUNT function also
> supports date, time and timestamp types.
> So, I think we should add a bitCount4MySQL implementation in SqlFunctions to
> adapt to different data types.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)