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

ASF GitHub Bot commented on DRILL-4456:
---------------------------------------

ihuzenko commented on a change in pull request #1527: DRILL-4456: Add Hive 
translate UDF
URL: https://github.com/apache/drill/pull/1527#discussion_r232305628
 
 

 ##########
 File path: 
contrib/storage-hive/core/src/main/java/org/apache/drill/exec/expr/fn/HiveFunctionRegistry.java
 ##########
 @@ -102,15 +116,15 @@ public void register(DrillOperatorTable operatorTable) {
     }
   }
 
-  private <C,I> void register(Class<? extends I> clazz, 
ArrayListMultimap<String,Class<? extends I>> methods) {
+  private <I> void register(Class<? extends I> clazz, 
ArrayListMultimap<String, Class<? extends I>> methods) {
 
 Review comment:
   If it's not required to have separate renameUDF(names) method, then it's 
possible to simplify body of this method: 
   
   ```
   private <C, I> void register(Class<? extends I> clazz, 
ArrayListMultimap<String, Class<? extends I>> methods) {
       Description desc = clazz.getAnnotation(Description.class);
       Stream<String> names;
       if (desc != null) {
         names = Stream.of(desc.name().split(",")).map(String::trim);
       } else {
         names = Stream.of(clazz).map(Class::getName)
             .map(name -> name.replace('.', '_'));
       }
       names.map(String::toLowerCase)
           .map(funName -> FUNCTION_REPLACE_MAP.getOrDefault(funName, funName))
           .forEach(udfFunName -> methods.put(udfFunName, clazz));
   
       UDFType type = clazz.getAnnotation(UDFType.class);
       if (type != null && !type.deterministic()) {
         nonDeterministicUDFs.add(clazz);
       }
     }
   
   ```

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


> Hive translate function is not working
> --------------------------------------
>
>                 Key: DRILL-4456
>                 URL: https://issues.apache.org/jira/browse/DRILL-4456
>             Project: Apache Drill
>          Issue Type: Improvement
>          Components: Functions - Hive
>    Affects Versions: 1.5.0
>            Reporter: Arina Ielchiieva
>            Assignee: Volodymyr Vysotskyi
>            Priority: Major
>             Fix For: 1.15.0
>
>
> In Hive "select translate(name, 'A', 'B') from users" works fine.
> But in Drill "select translate(name, 'A', 'B') from hive.`users`" returns the 
> following error:
> org.apache.drill.common.exceptions.UserRemoteException: PARSE ERROR: 
> Encountered "," at line 1, column 22. Was expecting one of: "USING" ... "NOT" 
> ... "IN" ... "BETWEEN" ... "LIKE" ... "SIMILAR" ... "=" ... ">" ... "<" ... 
> "<=" ... ">=" ... "<>" ... "+" ... "-" ... "*" ... "/" ... "||" ... "AND" ... 
> "OR" ... "IS" ... "MEMBER" ... "SUBMULTISET" ... "MULTISET" ... "[" ... "." 
> ... "(" ... while parsing SQL query: select translate(name, 'A', 'B') from 
> hive.users ^ [Error Id: ba21956b-3285-4544-b3b2-fab68b95be1f on 
> localhost:31010]
> Root cause:
> Calcite follows the standard SQL reference.
> SQL reference,  ISO/IEC 9075-2:2011(E), section 6.30
> <character transliteration> ::=
>   TRANSLATE <left paren> <character value expression>
> USING <transliteration name> <right paren>
> To fix:
> 1. add support to translate (expession, from_string, to_string) alternative 
> syntax
> 2. add unit test in org.apache.drill.exec.fn.hive.TestInbuiltHiveUDFs
> Changes can be made directly in Calcite and then upgrade to appropriate 
> Calcite version. 



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

Reply via email to