Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-1881

User-defined function can't identify Date and TimeStamp when both exist

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.12.0
    • Fix Version/s: 1.14.0
    • Component/s: None
    • Labels:
      None

      Description

      define user-define class with two mehtod:

           evaluate(Date d);
           evaluate(TIMESTAMP t);
      
      The table  is :
          CREATE TABLE file_source (
          name VARCHAR,
          d    TIMESTAMP
         ) 
      

      and the sql is :

      CREATE TEMPORARY function 'TESTUDF' AS 'com.netease.sloth.server.actor.TestUDF';
      INSERT INTO db_sink SELECT name, TESTUDF(d) FROM file_source; 
      

      Calcite do not know which method should be call and get error:

      java.lang.AssertionError
      	at org.apache.calcite.sql.type.SqlTypeExplicitPrecedenceList.compareTypePrecedence(SqlTypeExplicitPrecedenceList.java:153)
      	at org.apache.calcite.sql.SqlUtil.bestMatch(SqlUtil.java:627)
      	at org.apache.calcite.sql.SqlUtil.filterRoutinesByTypePrecedence(SqlUtil.java:593)
      	at org.apache.calcite.sql.SqlUtil.lookupSubjectRoutines(SqlUtil.java:447)
      	at org.apache.calcite.sql.SqlUtil.lookupRoutine(SqlUtil.java:371)
      	at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:245)
      	at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:223)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:4882)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:4869)
      	at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:137)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1580)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1565)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:447)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:3671)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3180)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateInsert(SqlValidatorImpl.java:3845)
      	at org.apache.calcite.sql.SqlInsert.validate(SqlInsert.java:148)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:887)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:597)
      	at org.apache.calcite.prepare.PlannerImpl.validate(PlannerImpl.java:188)
      	at com.netease.sloth.server.plan.SlothPlanner.parseSqlDml(SlothPlanner.java:670)
      	at com.netease.sloth.server.actor.AbstractJobManager.handle(AbstractJobManager.java:165)
      	at com.netease.sloth.server.actor.MyTest.testRunJobLocal(MyTest.java:60)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
      	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
      	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
      	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                julianhyde Julian Hyde
                Reporter:
                yuqi yuqi
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: