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

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

Github user arina-ielchiieva commented on a diff in the pull request:

    https://github.com/apache/drill/pull/701#discussion_r102920945
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillSqlWorker.java
 ---
    @@ -50,13 +47,56 @@
       private DrillSqlWorker() {
       }
     
    +  /**
    +   * Converts sql query string into query physical plan.
    +   *
    +   * @param context query context
    +   * @param sql sql query
    +   * @return query physical plan
    +   */
       public static PhysicalPlan getPlan(QueryContext context, String sql) 
throws SqlParseException, ValidationException,
           ForemanSetupException {
         return getPlan(context, sql, null);
       }
     
    +  /**
    +   * Converts sql query string into query physical plan.
    +   * In case of any errors (that might occur due to missing function 
implementation),
    +   * checks if local function registry should be synchronized with remote 
function registry.
    +   * If sync took place, reloads drill operator table
    +   * (since functions were added to / removed from local function registry)
    +   * and attempts to converts sql query string into query physical plan 
one more time.
    +   *
    +   * @param context query context
    +   * @param sql sql query
    +   * @param textPlan text plan
    +   * @return query physical plan
    +   */
       public static PhysicalPlan getPlan(QueryContext context, String sql, 
Pointer<String> textPlan)
           throws ForemanSetupException {
    +    Pointer<String> textPlanCopy = textPlan == null ? null : new 
Pointer<>(textPlan.value);
    +    try {
    +      return getQueryPlan(context, sql, textPlan);
    +    } catch (Exception e) {
    --- End diff --
    
    Not to be engaged into enumerating possible exceptions (which can added in 
the code later), we are checking if remote and local function registries are in 
sync on any error. Such check may only affect on queries that will fail anyway. 
So if failure time will take a little bit longer, it won't make significant 
difference. But this will be removed when MVCC (multi-version concurrency 
control) will be implemented: when query will fail, we won't check if our 
function registry is up-to-date, since MVCC will ensure we have before query 
startup.


> Issues when overloading Drill native functions with dynamic UDFs
> ----------------------------------------------------------------
>
>                 Key: DRILL-4963
>                 URL: https://issues.apache.org/jira/browse/DRILL-4963
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Functions - Drill
>    Affects Versions: 1.9.0
>            Reporter: Roman
>            Assignee: Arina Ielchiieva
>             Fix For: Future
>
>         Attachments: subquery_udf-1.0.jar, subquery_udf-1.0-sources.jar, 
> test_overloading-1.0.jar, test_overloading-1.0-sources.jar
>
>
> I created jar file which overloads 3 DRILL native functions 
> (LOG(VARCHAR-REQUIRED), CURRENT_DATE(VARCHAR-REQUIRED) and 
> ABS(VARCHAR-REQUIRED,VARCHAR-REQUIRED)) and registered it as dynamic UDF.
> If I try to use my functions I will get errors:
> {code:xml}
> SELECT CURRENT_DATE('test') FROM (VALUES(1));
> {code}
> Error: FUNCTION ERROR: CURRENT_DATE does not support operand types (CHAR)
> SQL Query null
> {code:xml}
> SELECT ABS('test','test') FROM (VALUES(1));
> {code}
> Error: FUNCTION ERROR: ABS does not support operand types (CHAR,CHAR)
> SQL Query null
> {code:xml}
> SELECT LOG('test') FROM (VALUES(1));
> {code}
> Error: SYSTEM ERROR: DrillRuntimeException: Failure while materializing 
> expression in constant expression evaluator LOG('test').  Errors: 
> Error in expression at index -1.  Error: Missing function implementation: 
> castTINYINT(VARCHAR-REQUIRED).  Full expression: UNKNOWN EXPRESSION.
> But if I rerun all this queries after "DrillRuntimeException", they will run 
> correctly. It seems that Drill have not updated the function signature before 
> that error. Also if I add jar as usual UDF (copy jar to 
> /drill_home/jars/3rdparty and restart drillbits), all queries will run 
> correctly without errors.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to