[jira] [Commented] (FLINK-8352) Flink UI Reports No Error on Job Submission Failures

2018-01-07 Thread Ufuk Celebi (JIRA)

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

Ufuk Celebi commented on FLINK-8352:


[~Zentol], do you know whether this is handled in the recently refactored (in 
master) run jar endpoint?


> Flink UI Reports No Error on Job Submission Failures
> 
>
> Key: FLINK-8352
> URL: https://issues.apache.org/jira/browse/FLINK-8352
> Project: Flink
>  Issue Type: Bug
>  Components: Web Client
>Affects Versions: 1.4.0
>Reporter: Elias Levy
>
> If you submit a job jar via the web UI and it raises an exception when 
> started, the UI will report no error and will continue the show the animated 
> image that makes it seem as if it is working.  In addition, no error is 
> printed in the logs, unless the level is increased to at least DEBUG:
> {noformat}
> @40005a4c399202b87ebc DEBUG 
> org.apache.flink.runtime.webmonitor.RuntimeMonitorHandler - Error while 
> handling request.
> @40005a4c399202b8868c java.util.concurrent.CompletionException: 
> org.apache.flink.client.program.ProgramInvocationException: The program 
> caused an error: 
> @40005a4c399202b88a74 at 
> org.apache.flink.runtime.webmonitor.handlers.JarPlanHandler.lambda$handleJsonRequest$0(JarPlanHandler.java:68)
> @40005a4c399202b88e5c at 
> java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source)
> @40005a4c399202b8e44c at 
> java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
> @40005a4c399202b8e44c at java.util.concurrent.FutureTask.run(Unknown 
> Source)
> @40005a4c399202b8e834 at 
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown
>  Source)
> @40005a4c399202b8e834 at 
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown
>  Source)
> @40005a4c399202b8f3ec at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
> @40005a4c399202b8f7d4 at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> @40005a4c399202b8f7d4 at java.lang.Thread.run(Unknown Source)
> @40005a4c399202b8fbbc Caused by: 
> org.apache.flink.client.program.ProgramInvocationException: The program 
> caused an error: 
> @40005a4c399202b90b5c at 
> org.apache.flink.client.program.OptimizerPlanEnvironment.getOptimizedPlan(OptimizerPlanEnvironment.java:93)
> @40005a4c399202b90f44 at 
> org.apache.flink.client.program.ClusterClient.getOptimizedPlan(ClusterClient.java:334)
> @40005a4c399202b90f44 at 
> org.apache.flink.runtime.webmonitor.handlers.JarActionHandler.getJobGraphAndClassLoader(JarActionHandler.java:76)
> @40005a4c399202b91afc at 
> org.apache.flink.runtime.webmonitor.handlers.JarPlanHandler.lambda$handleJsonRequest$0(JarPlanHandler.java:57)
> @40005a4c399202b91afc ... 8 more
> @40005a4c399202b91ee4 Caused by: java.lang.ExceptionInInitializerError
> @40005a4c399202b91ee4 at 
> com.cisco.sbg.amp.flink.ioc_engine.IocEngine.main(IocEngine.scala)
> @40005a4c399202b922cc at 
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> @40005a4c399202b92a9c at 
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> @40005a4c399202b92a9c at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> @40005a4c399202b92e84 at java.lang.reflect.Method.invoke(Unknown 
> Source)
> @40005a4c399202b92e84 at 
> org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:525)
> @40005a4c399202b9326c at 
> org.apache.flink.client.program.PackagedProgram.invokeInteractiveModeForExecution(PackagedProgram.java:417)
> @40005a4c399202b93a3c at 
> org.apache.flink.client.program.OptimizerPlanEnvironment.getOptimizedPlan(OptimizerPlanEnvironment.java:83)
> @40005a4c399202b949dc ... 11 more
> @40005a4c399202b949dc Caused by: java.io.FileNotFoundException: 
> /data/jenkins/jobs/XXX/workspace/target/scala-2.11/scoverage-data/scoverage.measurements.55
>  (No such file or directory)
> @40005a4c399202b951ac at java.io.FileOutputStream.open0(Native Method)
> @40005a4c399202b951ac at java.io.FileOutputStream.open(Unknown Source)
> @40005a4c399202b9597c at java.io.FileOutputStream.(Unknown 
> Source)
> @40005a4c399202b9597c at java.io.FileWriter.(Unknown Source)
> @40005a4c399202b95d64 at 
> scoverage.Invoker$$anonfun$1.apply(Invoker.scala:42)
> @40005a4c399202b95d64 at 
> scoverage.Invoker$$anonfun$1.apply(Invoker.scala:42)
> @40005a4c399202b9614c at 
> scala.collection.concurrent.TrieMap.getOrElseUpdate(TrieMap.scala:901)
> @40005a4c399202b9614c at scoverage.Invoker$.invoked(Invoker.scala:42)
> 

[jira] [Assigned] (FLINK-3089) State API Should Support Data Expiration (State TTL)

2018-01-07 Thread Bowen Li (JIRA)

 [ 
https://issues.apache.org/jira/browse/FLINK-3089?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Bowen Li reassigned FLINK-3089:
---

Assignee: Bowen Li

> State API Should Support Data Expiration (State TTL)
> 
>
> Key: FLINK-3089
> URL: https://issues.apache.org/jira/browse/FLINK-3089
> Project: Flink
>  Issue Type: New Feature
>  Components: DataStream API, State Backends, Checkpointing
>Reporter: Niels Basjes
>Assignee: Bowen Li
>
> In some usecases (webanalytics) there is a need to have a state per visitor 
> on a website (i.e. keyBy(sessionid) ).
> At some point the visitor simply leaves and no longer creates new events (so 
> a special 'end of session' event will not occur).
> The only way to determine that a visitor has left is by choosing a timeout, 
> like "After 30 minutes no events we consider the visitor 'gone'".
> Only after this (chosen) timeout has expired should we discard this state.
> In the Trigger part of Windows we can set a timer and close/discard this kind 
> of information. But that introduces the buffering effect of the window (which 
> in some scenarios is unwanted).
> What I would like is to be able to set a timeout on a specific state which I 
> can update afterwards.
> This makes it possible to create a map function that assigns the right value 
> and that discards the state automatically.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Updated] (FLINK-8364) add getIterator() to ListState, and returns empty iterator when it has no value

2018-01-07 Thread Bowen Li (JIRA)

 [ 
https://issues.apache.org/jira/browse/FLINK-8364?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Bowen Li updated FLINK-8364:

Summary: add getIterator() to ListState, and returns empty iterator when it 
has no value  (was: ListState should return empty iterator rather than null 
when it has no value)

> add getIterator() to ListState, and returns empty iterator when it has no 
> value
> ---
>
> Key: FLINK-8364
> URL: https://issues.apache.org/jira/browse/FLINK-8364
> Project: Flink
>  Issue Type: Improvement
>  Components: State Backends, Checkpointing
>Affects Versions: 1.4.0
>Reporter: Bowen Li
>Assignee: Bowen Li
> Fix For: 1.5.0
>
>
> per discussion with [~stefanrichte...@gmail.com] in 
> https://github.com/apache/flink/pull/4963, we decide to have 
> {{ListState#get}} return empty iterator if it has no value in it.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (FLINK-8364) ListState should return empty iterator rather than null when it has no value

2018-01-07 Thread Bowen Li (JIRA)

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

Bowen Li commented on FLINK-8364:
-

[~fhueske] [~aljoscha] Sounds reasonable to me. Updating the ticket title

> ListState should return empty iterator rather than null when it has no value
> 
>
> Key: FLINK-8364
> URL: https://issues.apache.org/jira/browse/FLINK-8364
> Project: Flink
>  Issue Type: Improvement
>  Components: State Backends, Checkpointing
>Affects Versions: 1.4.0
>Reporter: Bowen Li
>Assignee: Bowen Li
> Fix For: 1.5.0
>
>
> per discussion with [~stefanrichte...@gmail.com] in 
> https://github.com/apache/flink/pull/4963, we decide to have 
> {{ListState#get}} return empty iterator if it has no value in it.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Assigned] (FLINK-8368) Port SubtaskExecutionAttemptDetailsHandler to new REST endpoint

2018-01-07 Thread Biao Liu (JIRA)

 [ 
https://issues.apache.org/jira/browse/FLINK-8368?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Biao Liu reassigned FLINK-8368:
---

Assignee: Biao Liu

> Port SubtaskExecutionAttemptDetailsHandler to new REST endpoint
> ---
>
> Key: FLINK-8368
> URL: https://issues.apache.org/jira/browse/FLINK-8368
> Project: Flink
>  Issue Type: Sub-task
>  Components: REST
>Reporter: Biao Liu
>Assignee: Biao Liu
>  Labels: flip-6
> Fix For: 1.5.0
>
>
> Migrate 
> org.apache.flink.runtime.rest.handler.legacy.SubtaskExecutionAttemptDetailsHandler
>  to new a REST handler that registered in WebMonitorEndpoint.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Assigned] (FLINK-8367) Port SubtaskCurrentAttemptDetailsHandler to new REST endpoint

2018-01-07 Thread Biao Liu (JIRA)

 [ 
https://issues.apache.org/jira/browse/FLINK-8367?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Biao Liu reassigned FLINK-8367:
---

Assignee: Biao Liu

> Port SubtaskCurrentAttemptDetailsHandler to new REST endpoint
> -
>
> Key: FLINK-8367
> URL: https://issues.apache.org/jira/browse/FLINK-8367
> Project: Flink
>  Issue Type: Sub-task
>  Components: REST
>Reporter: Biao Liu
>Assignee: Biao Liu
>  Labels: flip-6
> Fix For: 1.5.0
>
>
> Migrate 
> org.apache.flink.runtime.rest.handler.legacy.SubtaskCurrentAttemptDetailsHandler
>  to new a REST handler that registered in WebMonitorEndpoint.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Updated] (FLINK-8382) sheduleRunAsync with a positive schedule delay does not work in JobMaster

2018-01-07 Thread Zhu Zhu (JIRA)

 [ 
https://issues.apache.org/jira/browse/FLINK-8382?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Zhu Zhu updated FLINK-8382:
---
Description: 
Here's the process of invoking scheduleRunAsync in JM:
1. The method scheduleRunAsync in JobMaster will forward a RunAsync message to 
FencedAkkaRpcActor. 
2. FencedAkkaRpcActor handles it with method handleRunAsync from its parent 
class AkkaRpcActor: If the schedule delay is positive, handleRunAsync will 
schedule a raw RunAsync message without a FencedMessage/UnfencedMessage 
wrapped. 
3. Later when FencedAkkaRpcActor receives the scheduled raw RunAsync message, 
*it will discard the message for not recognizing the message type*. 

  was:
Here's the process of invoking scheduleRunAsync in JM:
1. The method scheduleRunAsync in JobMaster will forward a RunAsync message to 
FencedAkkaRpcActor. 
2. FencedAkkaRpcActor handles it with method handleRunAsync from its parent 
class AkkaRpcActor: If the schedule delay is positive, handleRunAsync will 
schedule a raw RunAsync message without a FencedMessage/UnfencedMessage 
wrapped. 
3. Later when FencedAkkaRpcActor receives the scheduled raw RunAsync message, 
it will discard it for not recognizing the message type. 

Thus the scheduleRunAsync does work.


> sheduleRunAsync with a positive schedule delay does not work in JobMaster
> -
>
> Key: FLINK-8382
> URL: https://issues.apache.org/jira/browse/FLINK-8382
> Project: Flink
>  Issue Type: Bug
>  Components: Distributed Coordination
>Affects Versions: 1.5.0
>Reporter: Zhu Zhu
>
> Here's the process of invoking scheduleRunAsync in JM:
> 1. The method scheduleRunAsync in JobMaster will forward a RunAsync message 
> to FencedAkkaRpcActor. 
> 2. FencedAkkaRpcActor handles it with method handleRunAsync from its parent 
> class AkkaRpcActor: If the schedule delay is positive, handleRunAsync will 
> schedule a raw RunAsync message without a FencedMessage/UnfencedMessage 
> wrapped. 
> 3. Later when FencedAkkaRpcActor receives the scheduled raw RunAsync message, 
> *it will discard the message for not recognizing the message type*. 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (FLINK-2055) Implement Streaming HBaseSink

2018-01-07 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on FLINK-2055:
---

Github user nielsbasjes commented on the issue:

https://github.com/apache/flink/pull/2332
  
FYI:
In close relation to this issue I submitted an enhancement at the HBase 
side to support these kinds of usecases much better:
https://issues.apache.org/jira/browse/HBASE-19486
https://issues.apache.org/jira/browse/HBASE-19673

Simply put: You can now specify a max time the records may be kept in the 
BufferedMutator. If they exceed this value then a flush will be done 
automatically.



> Implement Streaming HBaseSink
> -
>
> Key: FLINK-2055
> URL: https://issues.apache.org/jira/browse/FLINK-2055
> Project: Flink
>  Issue Type: New Feature
>  Components: Streaming Connectors
>Affects Versions: 0.9
>Reporter: Robert Metzger
>Assignee: Erli Ding
>
> As per : 
> http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/Write-Stream-to-HBase-td1300.html



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[GitHub] flink issue #2332: [FLINK-2055] Implement Streaming HBaseSink

2018-01-07 Thread nielsbasjes
Github user nielsbasjes commented on the issue:

https://github.com/apache/flink/pull/2332
  
FYI:
In close relation to this issue I submitted an enhancement at the HBase 
side to support these kinds of usecases much better:
https://issues.apache.org/jira/browse/HBASE-19486
https://issues.apache.org/jira/browse/HBASE-19673

Simply put: You can now specify a max time the records may be kept in the 
BufferedMutator. If they exceed this value then a flush will be done 
automatically.



---


[jira] [Commented] (FLINK-8322) support getting number of existing timers in TimerService

2018-01-07 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on FLINK-8322:
---

Github user StephanEwen commented on the issue:

https://github.com/apache/flink/pull/5236
  
If we want to implement something like that, we should tap into what the 
data structures give us anyways, so we don't add additional overhead. Its a bit 
tricky to do that, though, because especially for RocksDB, it is not easily 
possible to know the number of keys at any point in time (due to the LSM model 
and the lazy merging).


> support getting number of existing timers in TimerService
> -
>
> Key: FLINK-8322
> URL: https://issues.apache.org/jira/browse/FLINK-8322
> Project: Flink
>  Issue Type: Improvement
>  Components: DataStream API
>Affects Versions: 1.4.0
>Reporter: Bowen Li
>Assignee: Bowen Li
> Fix For: 1.5.0
>
>
> There are pretty common use cases where users want to use timers as scheduled 
> threads - e.g. add a timer to wake up x hours later and do something (reap 
> old data usually) only if there's no existing timers, basically we only want 
> at most 1 timer exists for the key all the time



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[GitHub] flink issue #5236: [FLINK-8322] support getting number of existing timers in...

2018-01-07 Thread StephanEwen
Github user StephanEwen commented on the issue:

https://github.com/apache/flink/pull/5236
  
If we want to implement something like that, we should tap into what the 
data structures give us anyways, so we don't add additional overhead. Its a bit 
tricky to do that, though, because especially for RocksDB, it is not easily 
possible to know the number of keys at any point in time (due to the LSM model 
and the lazy merging).


---


[jira] [Commented] (FLINK-8302) Support shift_left and shift_right in TableAPI

2018-01-07 Thread ASF GitHub Bot (JIRA)

[ 
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

2018-01-07 Thread ASF GitHub Bot (JIRA)

[ 
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

2018-01-07 Thread ASF GitHub Bot (JIRA)

[ 
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

2018-01-07 Thread ASF GitHub Bot (JIRA)

[ 
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

2018-01-07 Thread ASF GitHub Bot (JIRA)

[ 
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

2018-01-07 Thread ASF GitHub Bot (JIRA)

[ 
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

2018-01-07 Thread ASF GitHub Bot (JIRA)

[ 
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

2018-01-07 Thread ASF GitHub Bot (JIRA)

[ 
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

2018-01-07 Thread ASF GitHub Bot (JIRA)

[ 
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

2018-01-07 Thread ASF GitHub Bot (JIRA)

[ 
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

2018-01-07 Thread ASF GitHub Bot (JIRA)

[ 
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

2018-01-07 Thread ASF GitHub Bot (JIRA)

[ 
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

2018-01-07 Thread ASF GitHub Bot (JIRA)

[ 
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

2018-01-07 Thread ASF GitHub Bot (JIRA)

[ 
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

2018-01-07 Thread ASF GitHub Bot (JIRA)

[ 
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

2018-01-07 Thread ASF GitHub Bot (JIRA)

[ 
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)


[GitHub] flink pull request #5202: [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT ...

2018-01-07 Thread sunjincheng121
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.


---


[GitHub] flink pull request #5202: [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT ...

2018-01-07 Thread sunjincheng121
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.


---


[GitHub] flink pull request #5202: [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT ...

2018-01-07 Thread sunjincheng121
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.
  


---


[GitHub] flink pull request #5202: [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT ...

2018-01-07 Thread sunjincheng121
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.


---


[GitHub] flink pull request #5202: [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT ...

2018-01-07 Thread sunjincheng121
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"
)
```


---


[GitHub] flink pull request #5202: [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT ...

2018-01-07 Thread sunjincheng121
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.


---


[GitHub] flink pull request #5202: [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT ...

2018-01-07 Thread sunjincheng121
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.
  


---


[GitHub] flink pull request #5202: [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT ...

2018-01-07 Thread sunjincheng121
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.


---


[GitHub] flink pull request #5202: [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT ...

2018-01-07 Thread sunjincheng121
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.


---


[GitHub] flink pull request #5202: [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT ...

2018-01-07 Thread sunjincheng121
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.


---


[GitHub] flink pull request #5202: [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT ...

2018-01-07 Thread sunjincheng121
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` . 


---


[GitHub] flink pull request #5202: [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT ...

2018-01-07 Thread sunjincheng121
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.


---


[GitHub] flink pull request #5202: [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT ...

2018-01-07 Thread sunjincheng121
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` . 


---


[GitHub] flink pull request #5202: [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT ...

2018-01-07 Thread sunjincheng121
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.
  


---


[GitHub] flink pull request #5202: [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT ...

2018-01-07 Thread sunjincheng121
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.


---


[GitHub] flink pull request #5202: [FLINK-8302][table]Add SHIFT_LEFT and SHIFT_RIGHT ...

2018-01-07 Thread sunjincheng121
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"
)
```


---