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

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

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

 ##########
 File path: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala
 ##########
 @@ -196,6 +196,19 @@ object ScalarFunctions {
     new String(data)
   }
 
+  /**
+    * Returns the numeric value of the leftmost character of the string str.
+    * Returns 0 if str is the empty string. Returns NULL if str is NULL.
+    */
+  def ascii(str: String): String = {
+    if (str == null)
+      null
+    else if (str.equals(""))
+      ""
+    else
+      str.charAt(0).toInt.toString
 
 Review comment:
   Java is UTF-16. The result is wrong.

----------------------------------------------------------------
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 function for table/sql API
> ------------------------------------
>
>                 Key: FLINK-9970
>                 URL: https://issues.apache.org/jira/browse/FLINK-9970
>             Project: Flink
>          Issue Type: New Feature
>          Components: Table API & SQL
>            Reporter: vinoyang
>            Assignee: vinoyang
>            Priority: Minor
>              Labels: pull-request-available
>
> refer to : 
> https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_ascii



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

Reply via email to