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_r226515985
 
 

 ##########
 File path: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala
 ##########
 @@ -252,6 +252,17 @@ object ScalarFunctions {
     regexp_extract(str, regex, 0)
   }
 
+  /**
+    * Returns a numeric value of the leftmost character of the string str.
+    */
+  def ascii(str: String): Integer = {
+    if (str == null || str.equals("")) {
+      0
 
 Review comment:
   OK, I can return `null`. In the Java world, Integer is an object, and 
returning null is fine from a grammatical and semantic point of view. However, 
when we use ascii('') as input to other operators, such as 
xxxFunction(ascii('')). The subsequent effects of null and 0 are completely 
different. Null may produce NPE or other behavior, while 0 is different. If you 
have already considered this, then I have no problem 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


With regards,
Apache Git Services

Reply via email to