[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17336676#comment-17336676 ] Flink Jira Bot commented on FLINK-8302: --- This issue was labeled "stale-major" 7 ago and has not received any updates so it is being deprioritized. If this ticket is actually Major, please raise the priority and ask a committer to assign you the issue or revive the public discussion. > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table SQL / API >Reporter: DuBin >Priority: Major > Labels: features, pull-request-available, stale-major > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17328684#comment-17328684 ] Flink Jira Bot commented on FLINK-8302: --- This major issue is unassigned and itself and all of its Sub-Tasks have not been updated for 30 days. So, it has been labeled "stale-major". If this ticket is indeed "major", please either assign yourself or give an update. Afterwards, please remove the label. In 7 days the issue will be deprioritized. > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table SQL / API >Reporter: DuBin >Priority: Major > Labels: features, pull-request-available, stale-major > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16643000#comment-16643000 ] ASF GitHub Bot commented on FLINK-8302: --- pnowojski commented on a change in pull request #6445: [FLINK-8302] [table] Add SHIFT_LEFT and SHIFT_RIGHT URL: https://github.com/apache/flink/pull/6445#discussion_r223611554 ## File path: flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/ScalarOperatorsTest.scala ## @@ -74,6 +74,103 @@ class ScalarOperatorsTest extends ScalarOperatorsTestBase { "true") } + @Test + def testShiftLeft(): Unit = { +testAllApis( + 3.shiftLeft(3), + "3.shiftLeft(3)", + "shift_left(3,3)", + "24" +) + +testAllApis( + 2147483647.shiftLeft(-2147483648), + "2147483647.shiftLeft(-2147483648)", + "SHIFT_LEFT(2147483647,-2147483648)", + "2147483647" +) + +testAllApis( + -2147483648.shiftLeft(2147483647), Review comment: We need more tests for negative first argument's values This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API SQL >Reporter: DuBin >Priority: Major > Labels: features, pull-request-available > Fix For: 1.7.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16642999#comment-16642999 ] ASF GitHub Bot commented on FLINK-8302: --- pnowojski commented on a change in pull request #6445: [FLINK-8302] [table] Add SHIFT_LEFT and SHIFT_RIGHT URL: https://github.com/apache/flink/pull/6445#discussion_r223611234 ## File path: flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/ScalarOperatorsTest.scala ## @@ -74,6 +74,103 @@ class ScalarOperatorsTest extends ScalarOperatorsTestBase { "true") } + @Test + def testShiftLeft(): Unit = { +testAllApis( + 3.shiftLeft(3), Review comment: What happens with negative shift arguments? `3.shiftLeft(-3)`? Ditto for `shiftRight`? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API SQL >Reporter: DuBin >Priority: Major > Labels: features, pull-request-available > Fix For: 1.7.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16643001#comment-16643001 ] ASF GitHub Bot commented on FLINK-8302: --- pnowojski commented on a change in pull request #6445: [FLINK-8302] [table] Add SHIFT_LEFT and SHIFT_RIGHT URL: https://github.com/apache/flink/pull/6445#discussion_r223611771 ## File path: flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/ScalarOperatorsTest.scala ## @@ -74,6 +74,103 @@ class ScalarOperatorsTest extends ScalarOperatorsTestBase { "true") } + @Test + def testShiftLeft(): Unit = { +testAllApis( + 3.shiftLeft(3), + "3.shiftLeft(3)", + "shift_left(3,3)", + "24" +) + +testAllApis( + 2147483647.shiftLeft(-2147483648), + "2147483647.shiftLeft(-2147483648)", + "SHIFT_LEFT(2147483647,-2147483648)", + "2147483647" +) + +testAllApis( + -2147483648.shiftLeft(2147483647), + "-2147483648.shiftLeft(2147483647)", + "SHIFT_LEFT(-2147483648,2147483647)", + "0" +) + +testAllApis( + 9223372036854775807L.shiftLeft(-2147483648), + "9223372036854775807L.shiftLeft(-2147483648)", + "SHIFT_LEFT(9223372036854775807,-2147483648)", + "9223372036854775807" +) + +testAllApis( + 'f3.shiftLeft(5), + "f3.shiftLeft(5)", + "SHIFT_LEFT(f3,5)", + "32" +) + +testAllApis( + 1.shiftLeft(Null(Types.INT)), + "1.shiftLeft(Null(INT))", + "SHIFT_LEFT(1, CAST(NULL AS INT))", + "null" +) Review comment: What about other types? `TINYINT`? `SMALLINT`? What happens if you pass double or decimal? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API SQL >Reporter: DuBin >Priority: Major > Labels: features, pull-request-available > Fix For: 1.7.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16639935#comment-16639935 ] ASF GitHub Bot commented on FLINK-8302: --- twalthr commented on issue #6445: [FLINK-8302] [table] Add SHIFT_LEFT and SHIFT_RIGHT URL: https://github.com/apache/flink/pull/6445#issuecomment-427397780 @fhueske @pnowojski what is your opinion here? should we do the Spark/Hive way for now? We can still support other syntax in the future. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API SQL >Reporter: DuBin >Priority: Major > Labels: features, pull-request-available > Fix For: 1.7.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16634261#comment-16634261 ] ASF GitHub Bot commented on FLINK-8302: --- xueyumusic commented on issue #6445: [FLINK-8302] [table] Add SHIFT_LEFT and SHIFT_RIGHT URL: https://github.com/apache/flink/pull/6445#issuecomment-425967961 Thanks for review, @twalthr . I also think that it would be best if calcite could support << and >>, however I am not sure whether calcite could support this very well for two reason, one is that it looks bitwise shift operation is not sql standard and from [HIVE-9859](https://issues.apache.org/jira/browse/HIVE-9859) discussion it looks that ">>" has potential conflicts with nested complex type declaration in hive which also uses calcite. So maybe there are two ways: 1. As you said make calcite suport this. 2. Since [Spark](https://spark.apache.org/docs/2.3.0/api/sql/index.html#shiftleft) and [Hive](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF) both have shiftleft and shiftright, maybe we could also add this named as shiftleft and shiftright... Thanks This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API SQL >Reporter: DuBin >Priority: Major > Labels: features, pull-request-available > Fix For: 1.7.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16560975#comment-16560975 ] ASF GitHub Bot commented on FLINK-8302: --- yanghua commented on a change in pull request #6445: [FLINK-8302][Table API & SQL] Add SHIFT_LEFT and SHIFT_RIGHT URL: https://github.com/apache/flink/pull/6445#discussion_r205958595 ## File path: docs/dev/table/tableApi.md ## @@ -3598,6 +3598,28 @@ numeric1 % numeric2 + + +{% highlight scala %} +shiftLeft(numeric1, numeric2) Review comment: add Java doc for shiftLeft This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API SQL >Reporter: DuBin >Priority: Major > Labels: features, pull-request-available > Fix For: 1.6.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16560977#comment-16560977 ] ASF GitHub Bot commented on FLINK-8302: --- yanghua commented on a change in pull request #6445: [FLINK-8302][Table API & SQL] Add SHIFT_LEFT and SHIFT_RIGHT URL: https://github.com/apache/flink/pull/6445#discussion_r205958632 ## File path: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/scala/expressionDsl.scala ## @@ -831,6 +831,16 @@ trait ImplicitExpressionOperations { */ def notBetween(lowerBound: Expression, upperBound: Expression) = NotBetween(expr, lowerBound, upperBound) + + /* + * Left shift Review comment: provide more detail and end with "." looks better to me This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API SQL >Reporter: DuBin >Priority: Major > Labels: features, pull-request-available > Fix For: 1.6.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16560976#comment-16560976 ] ASF GitHub Bot commented on FLINK-8302: --- yanghua commented on a change in pull request #6445: [FLINK-8302][Table API & SQL] Add SHIFT_LEFT and SHIFT_RIGHT URL: https://github.com/apache/flink/pull/6445#discussion_r205958599 ## File path: docs/dev/table/tableApi.md ## @@ -3598,6 +3598,28 @@ numeric1 % numeric2 + + +{% highlight scala %} +shiftLeft(numeric1, numeric2) +{% endhighlight %} + + +Returns numeric1 shifted left of numeric2. The result is numeric1 << numeric2 + + + + + +{% highlight scala %} +shiftRight(numeric1, numeric2) Review comment: add Java doc for shiftRight This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API SQL >Reporter: DuBin >Priority: Major > Labels: features, pull-request-available > Fix For: 1.6.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16560978#comment-16560978 ] ASF GitHub Bot commented on FLINK-8302: --- yanghua commented on a change in pull request #6445: [FLINK-8302][Table API & SQL] Add SHIFT_LEFT and SHIFT_RIGHT URL: https://github.com/apache/flink/pull/6445#discussion_r205958635 ## File path: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/scala/expressionDsl.scala ## @@ -831,6 +831,16 @@ trait ImplicitExpressionOperations { */ def notBetween(lowerBound: Expression, upperBound: Expression) = NotBetween(expr, lowerBound, upperBound) + + /* + * Left shift + */ + def shiftLeft(right: Expression) = ShiftLeft(expr, right) + + /* + * Right shift Review comment: provide more detail and end with "." looks better to me This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API SQL >Reporter: DuBin >Priority: Major > Labels: features, pull-request-available > Fix For: 1.6.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16560671#comment-16560671 ] ASF GitHub Bot commented on FLINK-8302: --- xueyumusic opened a new pull request #6445: [FLINK-8302][Table API & SQL] Add SHIFT_LEFT and SHIFT_RIGHT URL: https://github.com/apache/flink/pull/6445 ## What is the purpose of the change This PR is based on the previous closed and unfinished work https://github.com/apache/flink/pull/5202, it adds shift left and right as core scalar operators in then code gen. The table api syntax is 21.shiftRight(1) and 21.shiftLeft(1) The sql syntax is SHIFT_RIGHT(21,1) ## Brief change log - *FunctionCatalog, expressionDsl and SHIFT_RIGHT(21,1)* - *CodeGenerator* ## Verifying this change This change added tests in ScalarOperatorsTest ## Does this pull request potentially affect one of the following parts: - Dependencies (does it add or upgrade a dependency): ( no) - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (no) - The serializers: (no) - The runtime per-record code paths (performance sensitive): (no) - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, ZooKeeper: (no) - The S3 file system connector: (no) ## Documentation - Does this pull request introduce a new feature? (yes) - If yes, how is the feature documented? (docs) This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API SQL >Reporter: DuBin >Priority: Major > Labels: features, pull-request-available > Fix For: 1.6.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16445084#comment-16445084 ] ASF GitHub Bot commented on FLINK-8302: --- Github user dubin555 closed the pull request at: https://github.com/apache/flink/pull/5202 > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API SQL >Reporter: DuBin >Priority: Major > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16443957#comment-16443957 ] ASF GitHub Bot commented on FLINK-8302: --- Github user twalthr commented on the issue: https://github.com/apache/flink/pull/5202 Are you able to update this PR @dubin555? Otherwise please close this PR and unassign yourself from the issue. Maybe somebody else wants to build on top of your code and finish this. Thanks. > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API SQL >Reporter: DuBin >Priority: Major > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16320558#comment-16320558 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r160730995 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/calls/FunctionGenerator.scala --- @@ -414,6 +414,34 @@ object FunctionGenerator { DOUBLE_TYPE_INFO, BuiltInMethods.LOG_WITH_BASE) + addSqlFunctionMethod( --- End diff -- Yes, that's correct.. +1 to add `shift` as a binary operator. > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16320308#comment-16320308 ] ASF GitHub Bot commented on FLINK-8302: --- Github user twalthr commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r160687249 --- Diff: flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/ScalarFunctionsTest.scala --- @@ -1216,6 +1216,74 @@ class ScalarFunctionsTest extends ScalarTypesTestBase { ) } + @Test + def testShiftLeft(): Unit = { +testSqlApi( --- End diff -- Add tests with null arguments. > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16320307#comment-16320307 ] ASF GitHub Bot commented on FLINK-8302: --- Github user twalthr commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r160687024 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/calls/FunctionGenerator.scala --- @@ -414,6 +414,34 @@ object FunctionGenerator { DOUBLE_TYPE_INFO, BuiltInMethods.LOG_WITH_BASE) + addSqlFunctionMethod( --- End diff -- Shift operations are core binary operators. I would not add them here but in `ScalarOperators`. Maybe we can already reuse `generateArithmeticOperator`. > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16318635#comment-16318635 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on the issue: https://github.com/apache/flink/pull/5202 Thanks @dubin555, The PR looks pretty good. +1 to merged. Thanks, Jincheng > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16317730#comment-16317730 ] ASF GitHub Bot commented on FLINK-8302: --- Github user dubin555 commented on the issue: https://github.com/apache/flink/pull/5202 Hi @sunjincheng121 , thanks for the overall review of my code. I've done some typo fix and add some test case base on your comment. Really appreciate for your careful review! Du Bin > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16315232#comment-16315232 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r160046913 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala --- @@ -109,4 +110,45 @@ object ScalarFunctions { Math.log(x) / Math.log(base) } } + + /** +* Returns the Int number after the input number left shift n bits +* @param input Int type +* @param n +* @return input << n +*/ + def shiftLeft(input: Int, n: Int): Int = { +input << n + } + + /** +* Returns the Long number after the input number left shift n bits +* @param input Long type +* @param n +* @return input << n +*/ + def shiftLeft(input: Long, n: Int): Long = { +input << n + } + + /** +* Returns the Int number after the input number right shift n bits +* @param input Int type --- End diff -- the base number to shift. > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16315226#comment-16315226 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r160046929 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala --- @@ -109,4 +110,45 @@ object ScalarFunctions { Math.log(x) / Math.log(base) } } + + /** +* Returns the Int number after the input number left shift n bits +* @param input Int type +* @param n +* @return input << n +*/ + def shiftLeft(input: Int, n: Int): Int = { +input << n + } + + /** +* Returns the Long number after the input number left shift n bits +* @param input Long type +* @param n +* @return input << n +*/ + def shiftLeft(input: Long, n: Int): Long = { +input << n + } + + /** +* Returns the Int number after the input number right shift n bits +* @param input Int type +* @param n --- End diff -- number of bits to right shift. > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16315230#comment-16315230 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r160047969 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/functions/sql/ScalarSqlFunctions.scala --- @@ -58,4 +58,22 @@ object ScalarSqlFunctions { OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC)), SqlFunctionCategory.NUMERIC) + val SHIFT_LEFT = new SqlFunction( +"SHIFT_LEFT", +SqlKind.OTHER_FUNCTION, +ReturnTypes.ARG0, +null, +OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.INTEGER), --- End diff -- I check the type defined in calcite, `SqlTypeFamily.INTEGER` is `SqlTypeName.INT_TYPES` contains `(TINYINT, SMALLINT, INTEGER, BIGINT)`, So we should change `SqlTypeFamily.NUMERIC` to `SqlTypeFamily.INTEGER` . > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16315219#comment-16315219 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r160046872 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala --- @@ -109,4 +110,45 @@ object ScalarFunctions { Math.log(x) / Math.log(base) } } + + /** +* Returns the Int number after the input number left shift n bits +* @param input Int type +* @param n +* @return input << n +*/ + def shiftLeft(input: Int, n: Int): Int = { +input << n + } + + /** +* Returns the Long number after the input number left shift n bits --- End diff -- Add . at the end of sentence. > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16315227#comment-16315227 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r160047972 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/functions/sql/ScalarSqlFunctions.scala --- @@ -58,4 +58,22 @@ object ScalarSqlFunctions { OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC)), SqlFunctionCategory.NUMERIC) + val SHIFT_LEFT = new SqlFunction( +"SHIFT_LEFT", +SqlKind.OTHER_FUNCTION, +ReturnTypes.ARG0, +null, +OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.INTEGER), +SqlFunctionCategory.NUMERIC + ) + + val SHIFT_RIGHT = new SqlFunction( +"SHIFT_RIGHT", +SqlKind.OTHER_FUNCTION, +ReturnTypes.ARG0, +null, +OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.INTEGER), --- End diff -- I check the type defined in calcite, `SqlTypeFamily.INTEGER` is `SqlTypeName.INT_TYPES` contains `(TINYINT, SMALLINT, INTEGER, BIGINT)`, So we should change `SqlTypeFamily.NUMERIC` to `SqlTypeFamily.INTEGER` . > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16315225#comment-16315225 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r160046879 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala --- @@ -109,4 +110,45 @@ object ScalarFunctions { Math.log(x) / Math.log(base) } } + + /** +* Returns the Int number after the input number left shift n bits +* @param input Int type +* @param n +* @return input << n +*/ + def shiftLeft(input: Int, n: Int): Int = { +input << n + } + + /** +* Returns the Long number after the input number left shift n bits +* @param input Long type +* @param n --- End diff -- number of bits to left shift. > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16315228#comment-16315228 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r160046823 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala --- @@ -109,4 +110,45 @@ object ScalarFunctions { Math.log(x) / Math.log(base) } } + + /** +* Returns the Int number after the input number left shift n bits +* @param input Int type +* @param n --- End diff -- the number of bits to left shift. > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16315221#comment-16315221 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r160046851 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala --- @@ -109,4 +110,45 @@ object ScalarFunctions { Math.log(x) / Math.log(base) } } + + /** +* Returns the Int number after the input number left shift n bits --- End diff -- Please add `.` at the end of sentence. > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16315222#comment-16315222 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r160047012 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala --- @@ -109,4 +110,45 @@ object ScalarFunctions { Math.log(x) / Math.log(base) } } + + /** +* Returns the Int number after the input number left shift n bits +* @param input Int type +* @param n +* @return input << n +*/ + def shiftLeft(input: Int, n: Int): Int = { +input << n + } + + /** +* Returns the Long number after the input number left shift n bits +* @param input Long type +* @param n +* @return input << n +*/ + def shiftLeft(input: Long, n: Int): Long = { +input << n + } + + /** +* Returns the Int number after the input number right shift n bits +* @param input Int type +* @param n +* @return input >> n +*/ + def shiftRight(input: Int, n: Int): Int = { +input >> n + } + + /** +* Returns the Long number after the input number right shift n bits --- End diff -- Add `.` at the end of sentence. > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16315223#comment-16315223 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r160046817 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala --- @@ -109,4 +110,45 @@ object ScalarFunctions { Math.log(x) / Math.log(base) } } + + /** +* Returns the Int number after the input number left shift n bits +* @param input Int type --- End diff -- the base number to shift. > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16315224#comment-16315224 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r160046944 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala --- @@ -109,4 +110,45 @@ object ScalarFunctions { Math.log(x) / Math.log(base) } } + + /** +* Returns the Int number after the input number left shift n bits +* @param input Int type +* @param n +* @return input << n +*/ + def shiftLeft(input: Int, n: Int): Int = { +input << n + } + + /** +* Returns the Long number after the input number left shift n bits +* @param input Long type +* @param n +* @return input << n +*/ + def shiftLeft(input: Long, n: Int): Long = { +input << n + } + + /** +* Returns the Int number after the input number right shift n bits +* @param input Int type +* @param n +* @return input >> n +*/ + def shiftRight(input: Int, n: Int): Int = { +input >> n + } + + /** +* Returns the Long number after the input number right shift n bits +* @param input Long type +* @param n --- End diff -- number of bits to right shift. > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16315220#comment-16315220 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r160047888 --- Diff: flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/ScalarFunctionsTest.scala --- @@ -1216,6 +1216,64 @@ class ScalarFunctionsTest extends ScalarTypesTestBase { ) } + @Test + def testShiftLeft(): Unit = { +testSqlApi( + "SHIFT_LEFT(1,1)", + "2" +) + +testSqlApi( + "SHIFT_LEFT(21,1)", + "42" +) + +testSqlApi( + "SHIFT_LEFT(2147483647,-2147483648)", + "2147483647" +) + +testSqlApi( + "SHIFT_LEFT(-2147483648,2147483647)", + "0" +) + +testSqlApi( + "SHIFT_LEFT(9223372036854775807,-2147483648)", + "9223372036854775807" +) + } + + @Test + def testShiftRight(): Unit = { --- End diff -- Add a test case using column defined in `ScalarTypesTestBase `, just like as follow: ``` testSqlApi( "SHIFT_RIGHT(f4,1)", // f4 is BIGINT type "22" ) ``` > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16315229#comment-16315229 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r160046954 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala --- @@ -109,4 +110,45 @@ object ScalarFunctions { Math.log(x) / Math.log(base) } } + + /** +* Returns the Int number after the input number left shift n bits +* @param input Int type +* @param n +* @return input << n +*/ + def shiftLeft(input: Int, n: Int): Int = { +input << n + } + + /** +* Returns the Long number after the input number left shift n bits +* @param input Long type +* @param n +* @return input << n +*/ + def shiftLeft(input: Long, n: Int): Long = { +input << n + } + + /** +* Returns the Int number after the input number right shift n bits +* @param input Int type +* @param n +* @return input >> n +*/ + def shiftRight(input: Int, n: Int): Int = { +input >> n + } + + /** +* Returns the Long number after the input number right shift n bits +* @param input Long type --- End diff -- the base number to shift. > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16315233#comment-16315233 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r160047907 --- Diff: flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/ScalarFunctionsTest.scala --- @@ -1216,6 +1216,64 @@ class ScalarFunctionsTest extends ScalarTypesTestBase { ) } + @Test + def testShiftLeft(): Unit = { --- End diff -- Add a test case using column defined in `ScalarTypesTestBase `, just like as follow: ``` testSqlApi( "SHIFT_LEFT(f4,1)", // f4 is BIGINT type "88" ) ``` > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16315231#comment-16315231 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r160046904 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala --- @@ -109,4 +110,45 @@ object ScalarFunctions { Math.log(x) / Math.log(base) } } + + /** +* Returns the Int number after the input number left shift n bits +* @param input Int type +* @param n +* @return input << n +*/ + def shiftLeft(input: Int, n: Int): Int = { +input << n + } + + /** +* Returns the Long number after the input number left shift n bits +* @param input Long type +* @param n +* @return input << n +*/ + def shiftLeft(input: Long, n: Int): Long = { +input << n + } + + /** +* Returns the Int number after the input number right shift n bits --- End diff -- Add `.` at the end of sentence. > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16315218#comment-16315218 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r160046875 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala --- @@ -109,4 +110,45 @@ object ScalarFunctions { Math.log(x) / Math.log(base) } } + + /** +* Returns the Int number after the input number left shift n bits +* @param input Int type +* @param n +* @return input << n +*/ + def shiftLeft(input: Int, n: Int): Int = { +input << n + } + + /** +* Returns the Long number after the input number left shift n bits +* @param input Long type --- End diff -- the base number to shift. > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16307394#comment-16307394 ] ASF GitHub Bot commented on FLINK-8302: --- Github user dubin555 commented on the issue: https://github.com/apache/flink/pull/5202 Hi @sunjincheng121 . Thanks for the review. I already finished some changed for code cleaning and remove the duplicate test case base on your comment. There are some similar implements in other Database, like MySQL, https://dev.mysql.com/doc/refman/5.7/en/bit-functions.html Oracle, https://docs.oracle.com/cd/E22583_01/DR/help/BitShift.html In Apache Spark, also exists similar implements, https://issues.apache.org/jira/browse/SPARK-8223 Thanks, Du Bin > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16307391#comment-16307391 ] ASF GitHub Bot commented on FLINK-8302: --- Github user dubin555 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r159151505 --- Diff: flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/ScalarFunctionsTest.scala --- @@ -1216,6 +1216,69 @@ class ScalarFunctionsTest extends ScalarTypesTestBase { ) } + @Test + def testShiftLeft(): Unit = { +testSqlApi( + "SHIFT_LEFT(1,1)", + "2" +) + +testSqlApi( + "SHIFT_LEFT(21,1)", + "42" +) + +testSqlApi( + "SHIFT_LEFT(21,1)", + "42" +) + --- End diff -- removed > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16307349#comment-16307349 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r159148340 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala --- @@ -109,4 +110,75 @@ object ScalarFunctions { Math.log(x) / Math.log(base) } } + + /** +* Returns the Int number after the input number left shift n bits +* @param input Int type +* @param n +* @return input << n +*/ + def shiftLeft(input: Int, n: Int): Int = { +_shiftLeft(input, n).asInstanceOf[Int] + } + + /** +* Returns the Long number after the input number left shift n bits +* @param input Long type +* @param n +* @return input << n +*/ + def shiftLeft(input: Long, n: Int): Long = { +_shiftLeft(input, n).asInstanceOf[Long] + } + + /** +* Returns the Int number after the input number right shift n bits +* @param input Int type +* @param n +* @return input >> n +*/ + def shiftRight(input: Int, n: Int): Int = { +_shiftRight(input, n).asInstanceOf[Int] + } + + /** +* Returns the Long number after the input number right shift n bits +* @param input Long type +* @param n +* @return input >> n +*/ + def shiftRight(input: Long, n: Int): Long = { +_shiftRight(input, n).asInstanceOf[Long] + } + + /** +* Returns the number after the input number left shift n bits +* Input must be type 'Long' or type 'Int' +*/ + private def _shiftLeft(input: Any, n: Int): Any = { +input match { + case l: jl.Long => l << n + case i: jl.Integer => i << n + case _ => +throw new IllegalArgumentException( + s"type of input in function 'shiftLeft(input, n)' must be Long or Integer" +) +} + } + + /** +* Returns the number after the input number right shift n bits +* Input must be type 'Long' or type 'Int' +*/ + private def _shiftRight(input: Any, n: Int): Any = { +input match { + case l: jl.Long => l >> n + case i: jl.Integer => i >> n + case _ => +throw new IllegalArgumentException( --- End diff -- never run here? > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16307346#comment-16307346 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r159148351 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala --- @@ -109,4 +110,75 @@ object ScalarFunctions { Math.log(x) / Math.log(base) } } + + /** +* Returns the Int number after the input number left shift n bits +* @param input Int type +* @param n +* @return input << n +*/ + def shiftLeft(input: Int, n: Int): Int = { +_shiftLeft(input, n).asInstanceOf[Int] + } + + /** +* Returns the Long number after the input number left shift n bits +* @param input Long type +* @param n +* @return input << n +*/ + def shiftLeft(input: Long, n: Int): Long = { +_shiftLeft(input, n).asInstanceOf[Long] + } + + /** +* Returns the Int number after the input number right shift n bits +* @param input Int type +* @param n +* @return input >> n +*/ + def shiftRight(input: Int, n: Int): Int = { +_shiftRight(input, n).asInstanceOf[Int] + } + + /** +* Returns the Long number after the input number right shift n bits +* @param input Long type +* @param n +* @return input >> n +*/ + def shiftRight(input: Long, n: Int): Long = { +_shiftRight(input, n).asInstanceOf[Long] --- End diff -- input >> n > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16307348#comment-16307348 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r159148053 --- Diff: flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/ScalarFunctionsTest.scala --- @@ -1216,6 +1216,69 @@ class ScalarFunctionsTest extends ScalarTypesTestBase { ) } + @Test + def testShiftLeft(): Unit = { +testSqlApi( + "SHIFT_LEFT(1,1)", + "2" +) + +testSqlApi( + "SHIFT_LEFT(21,1)", + "42" +) + +testSqlApi( + "SHIFT_LEFT(21,1)", + "42" +) + --- End diff -- Remove duplicate test case. > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16307351#comment-16307351 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r159148349 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala --- @@ -109,4 +110,75 @@ object ScalarFunctions { Math.log(x) / Math.log(base) } } + + /** +* Returns the Int number after the input number left shift n bits +* @param input Int type +* @param n +* @return input << n +*/ + def shiftLeft(input: Int, n: Int): Int = { +_shiftLeft(input, n).asInstanceOf[Int] + } + + /** +* Returns the Long number after the input number left shift n bits +* @param input Long type +* @param n +* @return input << n +*/ + def shiftLeft(input: Long, n: Int): Long = { +_shiftLeft(input, n).asInstanceOf[Long] + } + + /** +* Returns the Int number after the input number right shift n bits +* @param input Int type +* @param n +* @return input >> n +*/ + def shiftRight(input: Int, n: Int): Int = { +_shiftRight(input, n).asInstanceOf[Int] --- End diff -- input >> n > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16307354#comment-16307354 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r159148352 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala --- @@ -109,4 +110,75 @@ object ScalarFunctions { Math.log(x) / Math.log(base) } } + + /** +* Returns the Int number after the input number left shift n bits +* @param input Int type +* @param n +* @return input << n +*/ + def shiftLeft(input: Int, n: Int): Int = { +_shiftLeft(input, n).asInstanceOf[Int] + } + + /** +* Returns the Long number after the input number left shift n bits +* @param input Long type +* @param n +* @return input << n +*/ + def shiftLeft(input: Long, n: Int): Long = { +_shiftLeft(input, n).asInstanceOf[Long] + } + + /** +* Returns the Int number after the input number right shift n bits +* @param input Int type +* @param n +* @return input >> n +*/ + def shiftRight(input: Int, n: Int): Int = { +_shiftRight(input, n).asInstanceOf[Int] + } + + /** +* Returns the Long number after the input number right shift n bits +* @param input Long type +* @param n +* @return input >> n +*/ + def shiftRight(input: Long, n: Int): Long = { +_shiftRight(input, n).asInstanceOf[Long] + } + + /** +* Returns the number after the input number left shift n bits +* Input must be type 'Long' or type 'Int' +*/ + private def _shiftLeft(input: Any, n: Int): Any = { --- End diff -- remove this method? > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16307347#comment-16307347 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r159148345 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala --- @@ -109,4 +110,75 @@ object ScalarFunctions { Math.log(x) / Math.log(base) } } + + /** +* Returns the Int number after the input number left shift n bits +* @param input Int type +* @param n +* @return input << n +*/ + def shiftLeft(input: Int, n: Int): Int = { +_shiftLeft(input, n).asInstanceOf[Int] --- End diff -- input << n ? > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16307353#comment-16307353 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r159148353 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala --- @@ -109,4 +110,75 @@ object ScalarFunctions { Math.log(x) / Math.log(base) } } + + /** +* Returns the Int number after the input number left shift n bits +* @param input Int type +* @param n +* @return input << n +*/ + def shiftLeft(input: Int, n: Int): Int = { +_shiftLeft(input, n).asInstanceOf[Int] + } + + /** +* Returns the Long number after the input number left shift n bits +* @param input Long type +* @param n +* @return input << n +*/ + def shiftLeft(input: Long, n: Int): Long = { +_shiftLeft(input, n).asInstanceOf[Long] + } + + /** +* Returns the Int number after the input number right shift n bits +* @param input Int type +* @param n +* @return input >> n +*/ + def shiftRight(input: Int, n: Int): Int = { +_shiftRight(input, n).asInstanceOf[Int] + } + + /** +* Returns the Long number after the input number right shift n bits +* @param input Long type +* @param n +* @return input >> n +*/ + def shiftRight(input: Long, n: Int): Long = { +_shiftRight(input, n).asInstanceOf[Long] + } + + /** +* Returns the number after the input number left shift n bits +* Input must be type 'Long' or type 'Int' +*/ + private def _shiftLeft(input: Any, n: Int): Any = { +input match { + case l: jl.Long => l << n + case i: jl.Integer => i << n + case _ => +throw new IllegalArgumentException( + s"type of input in function 'shiftLeft(input, n)' must be Long or Integer" +) +} + } + + /** +* Returns the number after the input number right shift n bits +* Input must be type 'Long' or type 'Int' +*/ + private def _shiftRight(input: Any, n: Int): Any = { --- End diff -- remove this method? > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16307350#comment-16307350 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r159148346 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala --- @@ -109,4 +110,75 @@ object ScalarFunctions { Math.log(x) / Math.log(base) } } + + /** +* Returns the Int number after the input number left shift n bits +* @param input Int type +* @param n +* @return input << n +*/ + def shiftLeft(input: Int, n: Int): Int = { +_shiftLeft(input, n).asInstanceOf[Int] + } + + /** +* Returns the Long number after the input number left shift n bits +* @param input Long type +* @param n +* @return input << n +*/ + def shiftLeft(input: Long, n: Int): Long = { +_shiftLeft(input, n).asInstanceOf[Long] --- End diff -- input << n > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16307355#comment-16307355 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r159148499 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/functions/sql/ScalarSqlFunctions.scala --- @@ -58,4 +58,22 @@ object ScalarSqlFunctions { OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC)), SqlFunctionCategory.NUMERIC) + val SHIFT_LEFT = new SqlFunction( +"SHIFT_LEFT", +SqlKind.OTHER_FUNCTION, +ReturnTypes.ARG0, +null, +OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC), --- End diff -- Second operand should be SqlTypeFamily.INTEGER. `OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC) -> OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.INTEGER) ` > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16307352#comment-16307352 ] ASF GitHub Bot commented on FLINK-8302: --- Github user sunjincheng121 commented on a diff in the pull request: https://github.com/apache/flink/pull/5202#discussion_r159148500 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/functions/sql/ScalarSqlFunctions.scala --- @@ -58,4 +58,22 @@ object ScalarSqlFunctions { OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC)), SqlFunctionCategory.NUMERIC) + val SHIFT_LEFT = new SqlFunction( +"SHIFT_LEFT", +SqlKind.OTHER_FUNCTION, +ReturnTypes.ARG0, +null, +OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC), +SqlFunctionCategory.NUMERIC + ) + + val SHIFT_RIGHT = new SqlFunction( +"SHIFT_RIGHT", +SqlKind.OTHER_FUNCTION, +ReturnTypes.ARG0, +null, +OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC), +SqlFunctionCategory.NUMERIC --- End diff -- Second operand should be SqlTypeFamily.INTEGER. `OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC) -> OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.INTEGER) ` > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16300755#comment-16300755 ] ASF GitHub Bot commented on FLINK-8302: --- GitHub user dubin555 opened a pull request: https://github.com/apache/flink/pull/5202 [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT supported in SQL In this PR, SHIFT_LEFT and SHIFT_RIGHT are added. ## General The pull request references the related JIRA issue, [FLINK-8302]Support shift_left and shift_right in TableAPI The pull request addresses only one issue Each commit in the PR has a meaningful commit message (including the JIRA id) ## Tests & Build Functionality added by the pull request is covered by tests ## Documentation Does this pull request introduce a new feature? (yes ) If yes, how is the feature documented? (docs / JavaDocs) You can merge this pull request into a Git repository by running: $ git pull https://github.com/dubin555/flink master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/flink/pull/5202.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #5202 commit 3db3a65178a91fce8d92b741cf58d4e02c96212e Author: DuBinDate: 2017-12-21T09:02:33Z [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT supported in SQL commit 89ac219a65e4b6b0dc03873b13b8b997cfb474fe Author: DuBin Date: 2017-12-21T10:00:19Z [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT supported in SQL commit 4212107079b5b5a5d7d2669bc106b2463f0e8f7d Author: DuBin Date: 2017-12-21T10:11:01Z [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT supported in SQL commit 28852dffdeeb4facb95b84e0294fea7788e7eaed Author: DuBin Date: 2017-12-22T00:14:28Z [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT supported in SQL > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16299939#comment-16299939 ] ASF GitHub Bot commented on FLINK-8302: --- Github user dubin555 closed the pull request at: https://github.com/apache/flink/pull/5198 > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16299827#comment-16299827 ] ASF GitHub Bot commented on FLINK-8302: --- GitHub user dubin555 opened a pull request: https://github.com/apache/flink/pull/5198 [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT supported in SQL In this PR, SHIFT_LEFT and SHIFT_RIGHT are added. General The pull request references the related JIRA issue, [FLINK-8302]Support shift_left and shift_right in TableAPI The pull request addresses only one issue Each commit in the PR has a meaningful commit message (including the JIRA id) Tests & Build Functionality added by the pull request is covered by tests Documentation Does this pull request introduce a new feature? (yes ) If yes, how is the feature documented? (docs / JavaDocs) You can merge this pull request into a Git repository by running: $ git pull https://github.com/dubin555/flink master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/flink/pull/5198.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #5198 commit 3db3a65178a91fce8d92b741cf58d4e02c96212e Author: DuBinDate: 2017-12-21T09:02:33Z [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT supported in SQL commit 89ac219a65e4b6b0dc03873b13b8b997cfb474fe Author: DuBin Date: 2017-12-21T10:00:19Z [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT supported in SQL commit 4212107079b5b5a5d7d2669bc106b2463f0e8f7d Author: DuBin Date: 2017-12-21T10:11:01Z [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT supported in SQL > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16299824#comment-16299824 ] ASF GitHub Bot commented on FLINK-8302: --- Github user dubin555 closed the pull request at: https://github.com/apache/flink/pull/5197 > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16299808#comment-16299808 ] ASF GitHub Bot commented on FLINK-8302: --- GitHub user dubin555 opened a pull request: https://github.com/apache/flink/pull/5197 [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT supported in SQL In this PR, SHIFT_LEFT and SHIFT_RIGHT are added. ## General - *The pull request references the related JIRA issue, [FLINK-8302]Support shift_left and shift_right in TableAPI* - *The pull request addresses only one issue* - *Each commit in the PR has a meaningful commit message (including the JIRA id)* ## Tests & Build - Functionality added by the pull request is covered by tests ## Documentation - Does this pull request introduce a new feature? (yes ) - If yes, how is the feature documented? (docs / JavaDocs) You can merge this pull request into a Git repository by running: $ git pull https://github.com/dubin555/flink master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/flink/pull/5197.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #5197 commit 3db3a65178a91fce8d92b741cf58d4e02c96212e Author: DuBinDate: 2017-12-21T09:02:33Z [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT supported in SQL commit 89ac219a65e4b6b0dc03873b13b8b997cfb474fe Author: DuBin Date: 2017-12-21T10:00:19Z [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT supported in SQL > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16299787#comment-16299787 ] ASF GitHub Bot commented on FLINK-8302: --- Github user dubin555 closed the pull request at: https://github.com/apache/flink/pull/5196 > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI
[ https://issues.apache.org/jira/browse/FLINK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16299757#comment-16299757 ] ASF GitHub Bot commented on FLINK-8302: --- GitHub user dubin555 opened a pull request: https://github.com/apache/flink/pull/5196 [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT supported in SQL In this PR, SHIFT_LEFT and SHIFT_RIGHT are added. *(General:)* - *The pull request references the related JIRA issue, [FLINK-8302]Support shift_left and shift_right in TableAPI* - *The pull request addresses only one issue* - *Each commit in the PR has a meaningful commit message (including the JIRA id)* ## Tests & Build - Functionality added by the pull request is covered by tests - mvn clean verify has been executed successfully locally or a Travis build has passed ## Documentation - Does this pull request introduce a new feature? (yes ) - If yes, how is the feature documented? (docs / JavaDocs) You can merge this pull request into a Git repository by running: $ git pull https://github.com/dubin555/flink master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/flink/pull/5196.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #5196 commit 3db3a65178a91fce8d92b741cf58d4e02c96212e Author: DuBinDate: 2017-12-21T09:02:33Z [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT supported in SQL > Support shift_left and shift_right in TableAPI > -- > > Key: FLINK-8302 > URL: https://issues.apache.org/jira/browse/FLINK-8302 > Project: Flink > Issue Type: Improvement > Components: Table API & SQL >Reporter: DuBin > Labels: features > Fix For: 1.5.0 > > Original Estimate: 48h > Remaining Estimate: 48h > > Add shift_left and shift_right support in TableAPI, shift_left(input, n) act > as input << n, shift_right(input, n) act as input >> n. -- This message was sent by Atlassian JIRA (v6.4.14#64029)