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

Ran Tao edited comment on FLINK-12449 at 2/26/23 4:05 AM:
----------------------------------------------------------

[~libenchao] thanks, benchao.

This issue is not actually created by me (it's an umbrella issue.), 
!image-2023-02-26-11-55-47-406.png|width=999,height=218!

I also have doubts. In fact, the functions related to *bit_or* and 
{*}bit_and{*}, such as in calcite, are an agg function, not a scalar function. 
I think the issue is also wrong here. It actually implements bit operations 
like a & b, a | b. For example, the same issue: 
https://issues.apache.org/jira/browse/FLINK-12451

!image-2023-02-26-11-56-21-005.png|width=523,height=283!

*Currently, flink does not support bit operations,*

Flink SQL> select 1+1 from t3;
{+}--{-}{{-}}{-}{-}{+}-----------+
|op|     EXPR$0|

{+}--{-}{{-}}{-}{-}{+}-----------+
|+I|          2|
|+I|          2|

{+}--{-}{{-}}{-}{-}{+}-----------+
Received a total of 2 rows

Flink SQL> select 1&1 from t3;

Exception in thread "main" org.apache.flink.table.client.SqlClientException: 
Could not read from command line.
    at 
org.apache.flink.table.client.cli.CliClient.getAndExecuteStatements(CliClient.java:205)
    at 
org.apache.flink.table.client.cli.CliClient.executeInteractive(CliClient.java:168)
    at 
org.apache.flink.table.client.cli.CliClient.executeInInteractiveMode(CliClient.java:113)
    at org.apache.flink.table.client.SqlClient.openCli(SqlClient.java:169)
    at org.apache.flink.table.client.SqlClient.start(SqlClient.java:118)
    at org.apache.flink.table.client.SqlClient.startClient(SqlClient.java:228)
    at org.apache.flink.table.client.SqlClient.main(SqlClient.java:179)
Caused by: org.apache.flink.sql.parser.impl.TokenMgrError: Lexical error at 
line 1, column 9.  Encountered: "&" (38), after : ""
    at 
org.apache.flink.sql.parser.impl.FlinkSqlParserImplTokenManager.getNextToken(FlinkSqlParserImplTokenManager.java:26752)
    at 
org.apache.flink.table.client.cli.parser.SqlCommandParserImpl$TokenIterator.scan(SqlCommandParserImpl.java:89)
    at 
org.apache.flink.table.client.cli.parser.SqlCommandParserImpl$TokenIterator.next(SqlCommandParserImpl.java:81)
    at 
org.apache.flink.table.client.cli.parser.SqlCommandParserImpl.checkIncompleteStatement(SqlCommandParserImpl.java:141)
    at 
org.apache.flink.table.client.cli.parser.SqlCommandParserImpl.getCommand(SqlCommandParserImpl.java:111)
    at 
org.apache.flink.table.client.cli.parser.SqlCommandParserImpl.parseStatement(SqlCommandParserImpl.java:52)
    at 
org.apache.flink.table.client.cli.parser.SqlMultiLineParser.parse(SqlMultiLineParser.java:82)
    at org.jline.reader.impl.LineReaderImpl.acceptLine(LineReaderImpl.java:2964)
    at org.jline.reader.impl.LineReaderImpl$1.apply(LineReaderImpl.java:3778)
    at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:679)
    at 
org.apache.flink.table.client.cli.CliClient.getAndExecuteStatements(CliClient.java:183)
    ... 6 more

*but this is a basic operation in other databases or languages. for example:*

mysql> select 1+2 from db;
+-----+
|1+2|

+-----+
|  3|
|  3|

+-----+
2 rows in set (0.00 sec)

mysql> select 1&2 from db;
+-----+
|1&2|

+-----+
|  0|
|  0|

+-----+
2 rows in set (0.00 sec)

mysql> select 1|2 from db;
+-----+
|1|2|

+-----+
|  3|
|  3|

+-----+
2 rows in set (0.00 sec)

mysql> select 1^2 from db;
+-----+
|1^2|

+-----+
|  3|
|  3|

+-----+
2 rows in set (0.00 sec)

please correct me. so i can change the description(could be a&b, a|b) of this 
issue. And finally support these bit-operations. cc [~twalthr] 


was (Author: lemonjing):
[~libenchao] thanks, benchao.

This issue is not actually created by me (it's an umbrella issue.), 
!image-2023-02-26-11-55-47-406.png|width=999,height=218!

I also have doubts. In fact, the functions related to *bit_or* and 
{*}bit_and{*}, such as in calcite, are an agg function, not a scalar function. 
I think the issue is also wrong here. It actually implements bit operations 
like a & b, a | b. For example, the same issue: 
https://issues.apache.org/jira/browse/FLINK-12451

!image-2023-02-26-11-56-21-005.png|width=523,height=283!

*Currently, flink does not support bit operations,*

Flink SQL> select 1+1 from t3;
{+}---{-}{-}{+}------------+
|op|     EXPR$0|

{+}---{-}{-}{+}------------+
|+I|          2|
|+I|          2|

{+}---{-}{-}{+}------------+
Received a total of 2 rows

Flink SQL> select 1&1 from t3;

Exception in thread "main" org.apache.flink.table.client.SqlClientException: 
Could not read from command line.
    at 
org.apache.flink.table.client.cli.CliClient.getAndExecuteStatements(CliClient.java:205)
    at 
org.apache.flink.table.client.cli.CliClient.executeInteractive(CliClient.java:168)
    at 
org.apache.flink.table.client.cli.CliClient.executeInInteractiveMode(CliClient.java:113)
    at org.apache.flink.table.client.SqlClient.openCli(SqlClient.java:169)
    at org.apache.flink.table.client.SqlClient.start(SqlClient.java:118)
    at org.apache.flink.table.client.SqlClient.startClient(SqlClient.java:228)
    at org.apache.flink.table.client.SqlClient.main(SqlClient.java:179)
Caused by: org.apache.flink.sql.parser.impl.TokenMgrError: Lexical error at 
line 1, column 9.  Encountered: "&" (38), after : ""
    at 
org.apache.flink.sql.parser.impl.FlinkSqlParserImplTokenManager.getNextToken(FlinkSqlParserImplTokenManager.java:26752)
    at 
org.apache.flink.table.client.cli.parser.SqlCommandParserImpl$TokenIterator.scan(SqlCommandParserImpl.java:89)
    at 
org.apache.flink.table.client.cli.parser.SqlCommandParserImpl$TokenIterator.next(SqlCommandParserImpl.java:81)
    at 
org.apache.flink.table.client.cli.parser.SqlCommandParserImpl.checkIncompleteStatement(SqlCommandParserImpl.java:141)
    at 
org.apache.flink.table.client.cli.parser.SqlCommandParserImpl.getCommand(SqlCommandParserImpl.java:111)
    at 
org.apache.flink.table.client.cli.parser.SqlCommandParserImpl.parseStatement(SqlCommandParserImpl.java:52)
    at 
org.apache.flink.table.client.cli.parser.SqlMultiLineParser.parse(SqlMultiLineParser.java:82)
    at org.jline.reader.impl.LineReaderImpl.acceptLine(LineReaderImpl.java:2964)
    at org.jline.reader.impl.LineReaderImpl$1.apply(LineReaderImpl.java:3778)
    at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:679)
    at 
org.apache.flink.table.client.cli.CliClient.getAndExecuteStatements(CliClient.java:183)
    ... 6 more

but this is a basic operation in other databases or languages. for example:

mysql> select 1+2 from db;
+-----+
|1+2|

+-----+
|  3|
|  3|

+-----+
2 rows in set (0.00 sec)

mysql> select 1&2 from db;
+-----+
|1&2|

+-----+
|  0|
|  0|

+-----+
2 rows in set (0.00 sec)

mysql> select 1|2 from db;
+-----+
|1|2|

+-----+
|  3|
|  3|

+-----+
2 rows in set (0.00 sec)

mysql> select 1^2 from db;
+-----+
|1^2|

+-----+
|  3|
|  3|

+-----+
2 rows in set (0.00 sec)

please correct me. so i can change the description(could be a&b, a|b) of this 
issue. And finally support these bit-operations. cc [~twalthr] 

> [Bitwise Functions] Add BIT_AND,  BIT_OR functions supported in Table API and 
> SQL
> ---------------------------------------------------------------------------------
>
>                 Key: FLINK-12449
>                 URL: https://issues.apache.org/jira/browse/FLINK-12449
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Table SQL / API
>            Reporter: Zhanchun Zhang
>            Priority: Major
>              Labels: auto-unassigned, pull-request-available
>         Attachments: image-2023-02-26-11-55-47-406.png, 
> image-2023-02-26-11-56-21-005.png
>
>
> Bitwise AND.
> eg. SELECT BIT_AND(29,15), returns 13 
> Bitwise OR
> eg. SELECT BIT_OR(29 ,15), returns 31



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

Reply via email to