[jira] [Commented] (FLINK-9853) add hex support in table api and sql

2018-08-14 Thread ASF GitHub Bot (JIRA)


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

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

twalthr commented on issue #6337: [FLINK-9853] [table] Add HEX support 
URL: https://github.com/apache/flink/pull/6337#issuecomment-412816367
 
 
   @xueyumusic for future PRs use `git rebase master YOURBRANCH` instead of 
merge commits. Thank you.


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


> add hex support in table api and sql
> 
>
> Key: FLINK-9853
> URL: https://issues.apache.org/jira/browse/FLINK-9853
> Project: Flink
>  Issue Type: Improvement
>  Components: Table API  SQL
>Reporter: xueyu
>Assignee: xueyu
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.7.0
>
>
> like in mysql, HEX could take int or string arguments, For a integer argument 
> N, it returns a hexadecimal string representation of the value of N. For a 
> string argument str, it returns a hexadecimal string representation of str 
> where each byte of each character in str is converted to two hexadecimal 
> digits. 
> Syntax:
> HEX(100) = 64
> HEX('This is a test String.') = '546869732069732061207465737420537472696e672e'
> See more: [link 
> MySQL|https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_hex]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (FLINK-9853) add hex support in table api and sql

2018-08-14 Thread ASF GitHub Bot (JIRA)


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

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

asfgit closed pull request #6337: [FLINK-9853] [table] Add HEX support 
URL: https://github.com/apache/flink/pull/6337
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/docs/dev/table/sql.md b/docs/dev/table/sql.md
index 148f30727d9..09b9b261b68 100644
--- a/docs/dev/table/sql.md
+++ b/docs/dev/table/sql.md
@@ -1675,6 +1675,17 @@ BIN(numeric)
   
 
 
+
+  
+{% highlight text %}
+HEX(numeric)
+HEX(string)
+  {% endhighlight %}
+  
+  
+Returns a string representation of an integer numeric value or a 
string in hex format. Returns null if numeric is null. E.g. For numeric "20" 
leads to "14", "100" leads to "64", and for string "hello,world" leads to 
"68656c6c6f2c776f726c64".
+  
+
   
 
 
diff --git a/docs/dev/table/tableApi.md b/docs/dev/table/tableApi.md
index b702dddcde5..b5dd4164a7d 100644
--- a/docs/dev/table/tableApi.md
+++ b/docs/dev/table/tableApi.md
@@ -2333,6 +2333,17 @@ NUMERIC.bin()
 

 
+
+ 
+   {% highlight java %}
+NUMERIC.hex()
+STRING.hex()
+{% endhighlight %}
+ 
+
+  Returns a string representation of an integer numeric value or a 
string in hex format. Returns null if numeric is null. E.g. For numeric "20" 
leads to "14", "100" leads to "64", and for string "hello,world" leads to 
"68656c6c6f2c776f726c64".
+
+   
   
 
 
@@ -3921,6 +3932,17 @@ NUMERIC.bin()
 

 
+
+ 
+   {% highlight scala %}
+NUMERIC.hex()
+STRING.hex()
+{% endhighlight %}
+ 
+
+  Returns a string representation of an integer numeric value or a 
string in hex format. Returns null if numeric is null. E.g. For numeric "20" 
leads to "14", "100" leads to "64", and for string "hello,world" leads to 
"68656c6c6f2c776f726c64".
+
+   
   
 
 
diff --git 
a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/scala/expressionDsl.scala
 
b/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/scala/expressionDsl.scala
index c7c805f6743..1df30d98d11 100644
--- 
a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/scala/expressionDsl.scala
+++ 
b/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/scala/expressionDsl.scala
@@ -406,6 +406,13 @@ trait ImplicitExpressionOperations {
 */
   def bin() = Bin(expr)
 
+  /**
+* Returns a string representation of an integer numeric value or a string 
in hex format.
+* Returns null if numeric or string is null. E.g. For numeric "20" leads 
to "14",
+* "100" leads to "64", and for string "hello,world" leads to 
"68656c6c6f2c776f726c64".
+*/
+  def hex() = Hex(expr)
+
   // String operations
 
   /**
diff --git 
a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/calls/BuiltInMethods.scala
 
b/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/calls/BuiltInMethods.scala
index f5ed9b387de..1e21bfe7830 100644
--- 
a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/calls/BuiltInMethods.scala
+++ 
b/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/calls/BuiltInMethods.scala
@@ -132,6 +132,11 @@ object BuiltInMethods {
 
   val BIN = Types.lookupMethod(classOf[JLong], "toBinaryString", classOf[Long])
 
+  val HEX = Types.lookupMethod(classOf[ScalarFunctions], "hex", classOf[Long])
+
+  val HEX_STRING =
+Types.lookupMethod(classOf[ScalarFunctions], "hexString", classOf[String])
+
   val FROMBASE64 = Types.lookupMethod(classOf[ScalarFunctions], "fromBase64", 
classOf[String])
 
   val TOBASE64 = Types.lookupMethod(classOf[ScalarFunctions], "toBase64", 
classOf[String])
diff --git 
a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/calls/FunctionGenerator.scala
 
b/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/calls/FunctionGenerator.scala
index 74b69d6afcc..47f54fb229c 100644
--- 
a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/calls/FunctionGenerator.scala
+++ 
b/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/calls/FunctionGenerator.scala
@@ -455,6 +455,18 @@ object FunctionGenerator {
 STRING_TYPE_INFO,
 BuiltInMethods.BIN)
 
+  addSqlFunctionMethod(
+ScalarSqlFunctions.HEX,
+Seq(LONG_TYPE_INFO),
+STRING_TYPE_INFO,
+BuiltInMethods.HEX)
+
+  addSqlFunctionMethod(
+ScalarSqlFunctions.HEX,
+Seq(STRING_TYPE_INFO),
+STRING_TYPE_INFO,
+BuiltInMethods.HEX_STRING)
+
   // 

[jira] [Commented] (FLINK-9853) add hex support in table api and sql

2018-08-14 Thread ASF GitHub Bot (JIRA)


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

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

twalthr commented on issue #6337: [FLINK-9853] [table] Add HEX support 
URL: https://github.com/apache/flink/pull/6337#issuecomment-412784892
 
 
   Thank you for the quick update @xueyumusic. I will merge this.


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


> add hex support in table api and sql
> 
>
> Key: FLINK-9853
> URL: https://issues.apache.org/jira/browse/FLINK-9853
> Project: Flink
>  Issue Type: Improvement
>  Components: Table API  SQL
>Reporter: xueyu
>Priority: Major
>  Labels: pull-request-available
>
> like in mysql, HEX could take int or string arguments, For a integer argument 
> N, it returns a hexadecimal string representation of the value of N. For a 
> string argument str, it returns a hexadecimal string representation of str 
> where each byte of each character in str is converted to two hexadecimal 
> digits. 
> Syntax:
> HEX(100) = 64
> HEX('This is a test String.') = '546869732069732061207465737420537472696e672e'
> See more: [link 
> MySQL|https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_hex]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (FLINK-9853) add hex support in table api and sql

2018-08-13 Thread ASF GitHub Bot (JIRA)


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

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

xueyumusic commented on a change in pull request #6337: [FLINK-9853] [table] 
Add HEX support 
URL: https://github.com/apache/flink/pull/6337#discussion_r209684500
 
 

 ##
 File path: 
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/ScalarFunctionsTest.scala
 ##
 @@ -392,6 +392,93 @@ class ScalarFunctionsTest extends ScalarTypesTestBase {
   "äää1234512345")
   }
 
+  @Test
+  def testHex(): Unit = {
+testAllApis(
+  100.hex(),
+  "100.hex()",
+  "HEX(100)",
+  "64")
+
+testAllApis(
+  'f2.hex(),
+  "f2.hex()",
+  "HEX(f2)",
+  "2a")
 
 Review comment:
   Yes, we should do it as well. Thanks @twalthr , I updated the code


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


> add hex support in table api and sql
> 
>
> Key: FLINK-9853
> URL: https://issues.apache.org/jira/browse/FLINK-9853
> Project: Flink
>  Issue Type: Improvement
>  Components: Table API  SQL
>Reporter: xueyu
>Priority: Major
>  Labels: pull-request-available
>
> like in mysql, HEX could take int or string arguments, For a integer argument 
> N, it returns a hexadecimal string representation of the value of N. For a 
> string argument str, it returns a hexadecimal string representation of str 
> where each byte of each character in str is converted to two hexadecimal 
> digits. 
> Syntax:
> HEX(100) = 64
> HEX('This is a test String.') = '546869732069732061207465737420537472696e672e'
> See more: [link 
> MySQL|https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_hex]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (FLINK-9853) add hex support in table api and sql

2018-08-13 Thread ASF GitHub Bot (JIRA)


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

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

twalthr commented on a change in pull request #6337: [FLINK-9853] [table] Add 
HEX support 
URL: https://github.com/apache/flink/pull/6337#discussion_r209582385
 
 

 ##
 File path: 
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/ScalarFunctionsTest.scala
 ##
 @@ -392,6 +392,93 @@ class ScalarFunctionsTest extends ScalarTypesTestBase {
   "äää1234512345")
   }
 
+  @Test
+  def testHex(): Unit = {
+testAllApis(
+  100.hex(),
+  "100.hex()",
+  "HEX(100)",
+  "64")
+
+testAllApis(
+  'f2.hex(),
+  "f2.hex()",
+  "HEX(f2)",
+  "2a")
 
 Review comment:
   MySQL returns upper-case letters. Should we do this as well?


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


> add hex support in table api and sql
> 
>
> Key: FLINK-9853
> URL: https://issues.apache.org/jira/browse/FLINK-9853
> Project: Flink
>  Issue Type: Improvement
>  Components: Table API  SQL
>Reporter: xueyu
>Priority: Major
>  Labels: pull-request-available
>
> like in mysql, HEX could take int or string arguments, For a integer argument 
> N, it returns a hexadecimal string representation of the value of N. For a 
> string argument str, it returns a hexadecimal string representation of str 
> where each byte of each character in str is converted to two hexadecimal 
> digits. 
> Syntax:
> HEX(100) = 64
> HEX('This is a test String.') = '546869732069732061207465737420537472696e672e'
> See more: [link 
> MySQL|https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_hex]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (FLINK-9853) add hex support in table api and sql

2018-08-13 Thread ASF GitHub Bot (JIRA)


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

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

twalthr commented on a change in pull request #6337: [FLINK-9853] [table] Add 
HEX support 
URL: https://github.com/apache/flink/pull/6337#discussion_r209582133
 
 

 ##
 File path: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/expressions/mathExpressions.scala
 ##
 @@ -422,3 +422,21 @@ case class Bin(child: Expression) extends UnaryExpression 
{
 relBuilder.call(ScalarSqlFunctions.BIN, child.toRexNode)
   }
 }
+
+case class Hex(child: Expression) extends UnaryExpression {
+  override private[flink] def resultType: TypeInformation[_] = 
BasicTypeInfo.STRING_TYPE_INFO
+
+  override private[flink] def validateInput(): ValidationResult = 
child.resultType match {
+case _: IntegerTypeInfo[_] =>
 
 Review comment:
   Rely on `TypeCheckUtils.isIntegerFamily` and `TypeCheckUtils#isString` 
instead.


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


> add hex support in table api and sql
> 
>
> Key: FLINK-9853
> URL: https://issues.apache.org/jira/browse/FLINK-9853
> Project: Flink
>  Issue Type: Improvement
>  Components: Table API  SQL
>Reporter: xueyu
>Priority: Major
>  Labels: pull-request-available
>
> like in mysql, HEX could take int or string arguments, For a integer argument 
> N, it returns a hexadecimal string representation of the value of N. For a 
> string argument str, it returns a hexadecimal string representation of str 
> where each byte of each character in str is converted to two hexadecimal 
> digits. 
> Syntax:
> HEX(100) = 64
> HEX('This is a test String.') = '546869732069732061207465737420537472696e672e'
> See more: [link 
> MySQL|https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_hex]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (FLINK-9853) add hex support in table api and sql

2018-08-08 Thread ASF GitHub Bot (JIRA)


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

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

walterddr commented on a change in pull request #6337: [FLINK-9853] [table] Add 
HEX support 
URL: https://github.com/apache/flink/pull/6337#discussion_r208630486
 
 

 ##
 File path: docs/dev/table/sql.md
 ##
 @@ -1664,6 +1664,17 @@ BIN(numeric)
   
 
 
+
+  
+{% highlight text %}
+HEX(numeric)
+HEX(string)
+  {% endhighlight %}
+  
+  
+Returns a string representation of an integer numeric value or a 
string in hex format. Returns null if numeric is null. E.g. "20" leads to "14", 
"100" leads to "64", "hello,world" leads to "68656c6c6f2c776f726c64".
 
 Review comment:
   great change and explanations. actually my point was to have `"20"` --> `` 
`20` `` with specifically the backtick. since backtick quoted strings gets 
format differently in Flink doc page and it will be immediately clear that this 
is a numeral literal. 


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


> add hex support in table api and sql
> 
>
> Key: FLINK-9853
> URL: https://issues.apache.org/jira/browse/FLINK-9853
> Project: Flink
>  Issue Type: Improvement
>  Components: Table API  SQL
>Reporter: xueyu
>Priority: Major
>  Labels: pull-request-available
>
> like in mysql, HEX could take int or string arguments, For a integer argument 
> N, it returns a hexadecimal string representation of the value of N. For a 
> string argument str, it returns a hexadecimal string representation of str 
> where each byte of each character in str is converted to two hexadecimal 
> digits. 
> Syntax:
> HEX(100) = 64
> HEX('This is a test String.') = '546869732069732061207465737420537472696e672e'
> See more: [link 
> MySQL|https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_hex]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (FLINK-9853) add hex support in table api and sql

2018-08-05 Thread ASF GitHub Bot (JIRA)


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

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

xueyumusic commented on a change in pull request #6337: [FLINK-9853] [table] 
Add HEX support 
URL: https://github.com/apache/flink/pull/6337#discussion_r207736696
 
 

 ##
 File path: docs/dev/table/sql.md
 ##
 @@ -1664,6 +1664,17 @@ BIN(numeric)
   
 
 
+
+  
+{% highlight text %}
+HEX(numeric)
+HEX(string)
+  {% endhighlight %}
+  
+  
+Returns a string representation of an integer numeric value or a 
string in hex format. Returns null if numeric is null. E.g. "20" leads to "14", 
"100" leads to "64", "hello,world" leads to "68656c6c6f2c776f726c64".
 
 Review comment:
   Thanks @walterddr , I clarify the doc adding explicit explain `for numeric` 
or `for string`


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


> add hex support in table api and sql
> 
>
> Key: FLINK-9853
> URL: https://issues.apache.org/jira/browse/FLINK-9853
> Project: Flink
>  Issue Type: Improvement
>  Components: Table API  SQL
>Reporter: xueyu
>Priority: Major
>  Labels: pull-request-available
>
> like in mysql, HEX could take int or string arguments, For a integer argument 
> N, it returns a hexadecimal string representation of the value of N. For a 
> string argument str, it returns a hexadecimal string representation of str 
> where each byte of each character in str is converted to two hexadecimal 
> digits. 
> Syntax:
> HEX(100) = 64
> HEX('This is a test String.') = '546869732069732061207465737420537472696e672e'
> See more: [link 
> MySQL|https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_hex]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (FLINK-9853) add hex support in table api and sql

2018-08-03 Thread ASF GitHub Bot (JIRA)


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

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

walterddr commented on a change in pull request #6337: [FLINK-9853] [table] Add 
HEX support 
URL: https://github.com/apache/flink/pull/6337#discussion_r207661219
 
 

 ##
 File path: docs/dev/table/sql.md
 ##
 @@ -1664,6 +1664,17 @@ BIN(numeric)
   
 
 
+
+  
+{% highlight text %}
+HEX(numeric)
+HEX(string)
+  {% endhighlight %}
+  
+  
+Returns a string representation of an integer numeric value or a 
string in hex format. Returns null if numeric is null. E.g. "20" leads to "14", 
"100" leads to "64", "hello,world" leads to "68656c6c6f2c776f726c64".
 
 Review comment:
   maybe consider using backtick for the number literals? e.g. `"20"` --> `` 
`20` ``. 
   
   Otherwise its confusing whether we should pass in stringify integer or just 
integer 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


> add hex support in table api and sql
> 
>
> Key: FLINK-9853
> URL: https://issues.apache.org/jira/browse/FLINK-9853
> Project: Flink
>  Issue Type: Improvement
>  Components: Table API  SQL
>Reporter: xueyu
>Priority: Major
>  Labels: pull-request-available
>
> like in mysql, HEX could take int or string arguments, For a integer argument 
> N, it returns a hexadecimal string representation of the value of N. For a 
> string argument str, it returns a hexadecimal string representation of str 
> where each byte of each character in str is converted to two hexadecimal 
> digits. 
> Syntax:
> HEX(100) = 64
> HEX('This is a test String.') = '546869732069732061207465737420537472696e672e'
> See more: [link 
> MySQL|https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_hex]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (FLINK-9853) add hex support in table api and sql

2018-08-03 Thread ASF GitHub Bot (JIRA)


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

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

walterddr commented on a change in pull request #6337: [FLINK-9853] [table] Add 
HEX support 
URL: https://github.com/apache/flink/pull/6337#discussion_r207661800
 
 

 ##
 File path: docs/dev/table/tableApi.md
 ##
 @@ -2322,6 +2322,17 @@ NUMERIC.bin()
 

 
+
+ 
+   {% highlight java %}
+NUMERIC.hex()
+STRING.hex()
+{% endhighlight %}
+ 
+
+  Returns a string representation of an integer numeric value or a 
string in hex format. Returns null if numeric is null. E.g. "20" leads to "14", 
"100" leads to "64", "hello,world" leads to "68656c6c6f2c776f726c64".
 
 Review comment:
   same here.


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


> add hex support in table api and sql
> 
>
> Key: FLINK-9853
> URL: https://issues.apache.org/jira/browse/FLINK-9853
> Project: Flink
>  Issue Type: Improvement
>  Components: Table API  SQL
>Reporter: xueyu
>Priority: Major
>  Labels: pull-request-available
>
> like in mysql, HEX could take int or string arguments, For a integer argument 
> N, it returns a hexadecimal string representation of the value of N. For a 
> string argument str, it returns a hexadecimal string representation of str 
> where each byte of each character in str is converted to two hexadecimal 
> digits. 
> Syntax:
> HEX(100) = 64
> HEX('This is a test String.') = '546869732069732061207465737420537472696e672e'
> See more: [link 
> MySQL|https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_hex]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (FLINK-9853) add hex support in table api and sql

2018-08-03 Thread ASF GitHub Bot (JIRA)


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

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

walterddr commented on a change in pull request #6337: [FLINK-9853] [table] Add 
HEX support 
URL: https://github.com/apache/flink/pull/6337#discussion_r207662596
 
 

 ##
 File path: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/scala/expressionDsl.scala
 ##
 @@ -406,6 +406,13 @@ trait ImplicitExpressionOperations {
 */
   def bin() = Bin(expr)
 
+  /**
+* Returns a string representation of an integer numeric value in hex 
format. Returns null if
+* numeric is null. E.g. "20" leads to "14", "100" leads to "64", 
"hello,world" leads to
 
 Review comment:
   just remove the `"` if it is numeric


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


> add hex support in table api and sql
> 
>
> Key: FLINK-9853
> URL: https://issues.apache.org/jira/browse/FLINK-9853
> Project: Flink
>  Issue Type: Improvement
>  Components: Table API  SQL
>Reporter: xueyu
>Priority: Major
>  Labels: pull-request-available
>
> like in mysql, HEX could take int or string arguments, For a integer argument 
> N, it returns a hexadecimal string representation of the value of N. For a 
> string argument str, it returns a hexadecimal string representation of str 
> where each byte of each character in str is converted to two hexadecimal 
> digits. 
> Syntax:
> HEX(100) = 64
> HEX('This is a test String.') = '546869732069732061207465737420537472696e672e'
> See more: [link 
> MySQL|https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_hex]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (FLINK-9853) add hex support in table api and sql

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


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

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

Github user hequn8128 commented on the issue:

https://github.com/apache/flink/pull/6337
  
Thanks for your PR. +1 to merge.


> add hex support in table api and sql
> 
>
> Key: FLINK-9853
> URL: https://issues.apache.org/jira/browse/FLINK-9853
> Project: Flink
>  Issue Type: Improvement
>  Components: Table API  SQL
>Reporter: xueyu
>Priority: Major
>  Labels: pull-request-available
>
> like in mysql, HEX could take int or string arguments, For a integer argument 
> N, it returns a hexadecimal string representation of the value of N. For a 
> string argument str, it returns a hexadecimal string representation of str 
> where each byte of each character in str is converted to two hexadecimal 
> digits. 
> Syntax:
> HEX(100) = 64
> HEX('This is a test String.') = '546869732069732061207465737420537472696e672e'
> See more: [link 
> MySQL|https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_hex]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (FLINK-9853) add hex support in table api and sql

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


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

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

Github user yanghua commented on the issue:

https://github.com/apache/flink/pull/6337
  
+1, from my side


> add hex support in table api and sql
> 
>
> Key: FLINK-9853
> URL: https://issues.apache.org/jira/browse/FLINK-9853
> Project: Flink
>  Issue Type: Improvement
>  Components: Table API  SQL
>Reporter: xueyu
>Priority: Major
>  Labels: pull-request-available
>
> like in mysql, HEX could take int or string arguments, For a integer argument 
> N, it returns a hexadecimal string representation of the value of N. For a 
> string argument str, it returns a hexadecimal string representation of str 
> where each byte of each character in str is converted to two hexadecimal 
> digits. 
> Syntax:
> HEX(100) = 64
> HEX('This is a test String.') = '546869732069732061207465737420537472696e672e'
> See more: [link 
> MySQL|https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_hex]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (FLINK-9853) add hex support in table api and sql

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


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

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

Github user xueyumusic commented on a diff in the pull request:

https://github.com/apache/flink/pull/6337#discussion_r202581145
  
--- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala
 ---
@@ -182,4 +184,6 @@ object ScalarFunctions {
 
 new String(data)
   }
+
+  def hex(x: String): String = Hex.encodeHexString(x.getBytes)
--- End diff --

thanks for review, @yanghua , fixed


> add hex support in table api and sql
> 
>
> Key: FLINK-9853
> URL: https://issues.apache.org/jira/browse/FLINK-9853
> Project: Flink
>  Issue Type: Improvement
>  Components: Table API  SQL
>Reporter: xueyu
>Priority: Major
>  Labels: pull-request-available
>
> like in mysql, HEX could take int or string arguments, For a integer argument 
> N, it returns a hexadecimal string representation of the value of N. For a 
> string argument str, it returns a hexadecimal string representation of str 
> where each byte of each character in str is converted to two hexadecimal 
> digits. 
> Syntax:
> HEX(100) = 64
> HEX('This is a test String.') = '546869732069732061207465737420537472696e672e'
> See more: [link 
> MySQL|https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_hex]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (FLINK-9853) add hex support in table api and sql

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


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

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

Github user yanghua commented on a diff in the pull request:

https://github.com/apache/flink/pull/6337#discussion_r202572746
  
--- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/scala/expressionDsl.scala
 ---
@@ -400,6 +400,12 @@ trait ImplicitExpressionOperations {
 * numeric is null. E.g. "4" leads to "100", "12" leads to "1100".
 */
   def bin() = Bin(expr)
+  /**
--- End diff --

please insert a new blank line


> add hex support in table api and sql
> 
>
> Key: FLINK-9853
> URL: https://issues.apache.org/jira/browse/FLINK-9853
> Project: Flink
>  Issue Type: Improvement
>  Components: Table API  SQL
>Reporter: xueyu
>Priority: Major
>  Labels: pull-request-available
>
> like in mysql, HEX could take int or string arguments, For a integer argument 
> N, it returns a hexadecimal string representation of the value of N. For a 
> string argument str, it returns a hexadecimal string representation of str 
> where each byte of each character in str is converted to two hexadecimal 
> digits. 
> Syntax:
> HEX(100) = 64
> HEX('This is a test String.') = '546869732069732061207465737420537472696e672e'
> See more: [link 
> MySQL|https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_hex]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (FLINK-9853) add hex support in table api and sql

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


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

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

Github user yanghua commented on a diff in the pull request:

https://github.com/apache/flink/pull/6337#discussion_r202573057
  
--- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala
 ---
@@ -182,4 +184,6 @@ object ScalarFunctions {
 
 new String(data)
   }
+
+  def hex(x: String): String = Hex.encodeHexString(x.getBytes)
--- End diff --

add the doc for the API looks better to me


> add hex support in table api and sql
> 
>
> Key: FLINK-9853
> URL: https://issues.apache.org/jira/browse/FLINK-9853
> Project: Flink
>  Issue Type: Improvement
>  Components: Table API  SQL
>Reporter: xueyu
>Priority: Major
>  Labels: pull-request-available
>
> like in mysql, HEX could take int or string arguments, For a integer argument 
> N, it returns a hexadecimal string representation of the value of N. For a 
> string argument str, it returns a hexadecimal string representation of str 
> where each byte of each character in str is converted to two hexadecimal 
> digits. 
> Syntax:
> HEX(100) = 64
> HEX('This is a test String.') = '546869732069732061207465737420537472696e672e'
> See more: [link 
> MySQL|https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_hex]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (FLINK-9853) add hex support in table api and sql

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


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

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

GitHub user xueyumusic opened a pull request:

https://github.com/apache/flink/pull/6337

[FLINK-9853][Tabel API & SQL] add HEX support 

## What is the purpose of the change
This PR propose to add HEX in table api and sql, the syntax like mysql, 
which could take int or string arguments. For a integer argument N, it returns 
a hexadecimal string representation of the value of N. For a string argument 
str, it returns a hexadecimal string representation of str where each byte of 
each character in str is converted to two hexadecimal digits. 

Syntax:

HEX(100) = 64

HEX('This is a test String.') = 
'546869732069732061207465737420537472696e672e'

## Brief change log
  - *The expressionDsl, scalarSqlFunctions and mathExpressions to add hex*
  - *The FunctionGenerator to support hex generator*

## Verifying this change

This change added tests and can be verified as follows:

*(example:)*
  - *Added ScalaFunctionTests tests for table api and sql expressions*

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


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/xueyumusic/flink hex

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/flink/pull/6337.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 #6337


commit 8d3bef913bee1d4913ef3ae056e3d15d4cda2cec
Author: xueyu <278006819@...>
Date:   2018-07-15T12:01:15Z

hex support




> add hex support in table api and sql
> 
>
> Key: FLINK-9853
> URL: https://issues.apache.org/jira/browse/FLINK-9853
> Project: Flink
>  Issue Type: Improvement
>  Components: Table API  SQL
>Reporter: xueyu
>Priority: Major
>  Labels: pull-request-available
>
> like in mysql, HEX could take int or string arguments, For a integer argument 
> N, it returns a hexadecimal string representation of the value of N. For a 
> string argument str, it returns a hexadecimal string representation of str 
> where each byte of each character in str is converted to two hexadecimal 
> digits. 
> Syntax:
> HEX(100) = 64
> HEX('This is a test String.') = '546869732069732061207465737420537472696e672e'
> See more: [link 
> MySQL|https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_hex]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)