chunweilei commented on a change in pull request #1095: [CALCITE-2599] add the 
ASCII function
URL: https://github.com/apache/calcite/pull/1095#discussion_r264007301
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
 ##########
 @@ -237,6 +238,12 @@ public static String initcap(String s) {
     return newS.toString();
   }
 
+  /** SQL ASCII(string) function. */
+  public static int ascii(String s) {
+    return s.length() == 0
+        ? 0 : s.substring(0, 1).getBytes(StandardCharsets.UTF_8)[0];
 
 Review comment:
   It looks like the behavior is vary from database system to database system.  
Such as:
   
   [PostgreSQL](http://www.postgresqltutorial.com/postgresql-ascii/) says the 
ASCII() function returns the Unicode code point of the character in the case of 
UTF-8.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to