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

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

yanghua commented on a change in pull request #6432: [FLINK-9970] [table] Add 
ASCII/CHR function for table/sql API
URL: https://github.com/apache/flink/pull/6432#discussion_r226526582
 
 

 ##########
 File path: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala
 ##########
 @@ -266,6 +268,21 @@ object ScalarFunctions {
     regexp_extract(str, regex, 0)
   }
 
+  /**
+    * Returns the ASCII code value of the leftmost character of the string str.
+    */
+  def ascii(str: String): Integer = {
+    if (str == null || str.equals("")) {
+      0
+    } else {
+      if (CharMatcher.ASCII.matches(str.charAt(0))) {
+        str.charAt(0).toByte.toInt
+      } else {
+        0
 
 Review comment:
   Hi @xccui I tried to change the value of this method that originally 
returned 0 to null, but both related tests throw NPE, I don't know if it is 
related to Integer. Can you try it?

----------------------------------------------------------------
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 ASCII/CHR function for table/sql API
> ----------------------------------------
>
>                 Key: FLINK-9970
>                 URL: https://issues.apache.org/jira/browse/FLINK-9970
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Table API & SQL
>            Reporter: vinoyang
>            Assignee: vinoyang
>            Priority: Minor
>              Labels: pull-request-available
>
> for ASCII function : 
> refer to : 
> [https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_ascii]
> for CHR function : 
> This function convert ASCII code to a character,
> refer to : [https://doc.ispirer.com/sqlways/Output/SQLWays-1-071.html]
> Considering "CHAR" always is a keyword in many database, so we use "CHR" 
> keyword.



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

Reply via email to