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

User-defined functions should work without explicit schema prefix

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • None

    Description

      It looks like user-defined-functions have to be fully qualified with schema name for unknown reason.

      I've played with `JdbcTest.testUserDefinedFunction` a bit.
      If using `con.setSchema("adhoc")` then `select "deptno" as p from EMPLOYEES` works, but `select my_double("deptno") ...` throws:

      ```
      java.lang.RuntimeException: exception while executing [select my_double("deptno") as p from EMPLOYEES]
      at net.hydromatic.optiq.test.OptiqAssert$AssertQuery.returns(OptiqAssert.java:779)
      at net.hydromatic.optiq.test.OptiqAssert$AssertQuery.returns(OptiqAssert.java:766)
      at net.hydromatic.optiq.test.JdbcTest.testUserDefinedFunction(JdbcTest.java:2695)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
      at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
      at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:65)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
      Caused by: java.lang.RuntimeException: With materializationsEnabled=false, limit=0
      at net.hydromatic.optiq.test.OptiqAssert.assertQuery(OptiqAssert.java:343)
      at net.hydromatic.optiq.test.OptiqAssert$AssertQuery.returns(OptiqAssert.java:775)
      ... 28 more
      Caused by: java.sql.SQLException: while executing SQL: select my_double("deptno") as p from EMPLOYEES
      at net.hydromatic.avatica.Helper.createException(Helper.java:40)
      at net.hydromatic.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:80)
      at net.hydromatic.optiq.test.OptiqAssert.assertQuery(OptiqAssert.java:318)
      ... 29 more
      Caused by: org.eigenbase.util.EigenbaseContextException: From line 1, column 8 to line 1, column 26
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
      at org.eigenbase.resource.Resources$ExInstWithCause.ex(Resources.java:348)
      at org.eigenbase.sql.SqlUtil.newContextException(SqlUtil.java:674)
      at org.eigenbase.sql.SqlUtil.newContextException(SqlUtil.java:662)
      at org.eigenbase.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:3504)
      at org.eigenbase.sql.validate.SqlValidatorImpl.handleUnresolvedFunction(SqlValidatorImpl.java:1406)
      at org.eigenbase.sql.SqlFunction.deriveType(SqlFunction.java:282)
      at org.eigenbase.sql.SqlFunction.deriveType(SqlFunction.java:206)
      at org.eigenbase.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:3862)
      at org.eigenbase.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:3849)
      at org.eigenbase.sql.SqlCall.accept(SqlCall.java:133)
      at org.eigenbase.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1323)
      at org.eigenbase.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1306)
      at org.eigenbase.sql.SqlAsOperator.deriveType(SqlAsOperator.java:117)
      at org.eigenbase.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:3862)
      at org.eigenbase.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:3849)
      at org.eigenbase.sql.SqlCall.accept(SqlCall.java:133)
      at org.eigenbase.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1323)
      at org.eigenbase.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1306)
      at org.eigenbase.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:416)
      at org.eigenbase.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:3010)
      at org.eigenbase.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:2763)
      at org.eigenbase.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
      at org.eigenbase.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:80)
      at org.eigenbase.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:745)
      at org.eigenbase.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:734)
      at org.eigenbase.sql.SqlSelect.validate(SqlSelect.java:209)
      at org.eigenbase.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:708)
      at org.eigenbase.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:424)
      at org.eigenbase.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:426)
      at net.hydromatic.optiq.prepare.Prepare.prepareSql(Prepare.java:209)
      at net.hydromatic.optiq.prepare.Prepare.prepareSql(Prepare.java:178)
      at net.hydromatic.optiq.prepare.OptiqPrepareImpl.prepare2_(OptiqPrepareImpl.java:334)
      at net.hydromatic.optiq.prepare.OptiqPrepareImpl.prepare_(OptiqPrepareImpl.java:243)
      at net.hydromatic.optiq.prepare.OptiqPrepareImpl.prepareSql(OptiqPrepareImpl.java:212)
      at net.hydromatic.optiq.jdbc.OptiqConnectionImpl.parseQuery(OptiqConnectionImpl.java:146)
      at net.hydromatic.optiq.jdbc.MetaImpl.prepare(MetaImpl.java:603)
      at net.hydromatic.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:77)
      ... 30 more
      Caused by: org.eigenbase.sql.validate.SqlValidatorException: No match found for function signature MY_DOUBLE(<NUMERIC>)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
      at org.eigenbase.resource.Resources$ExInstWithCause.ex(Resources.java:348)
      at org.eigenbase.resource.Resources$ExInst.ex(Resources.java:457)
      ... 66 more
      ```

      ---------------- Imported from GitHub ----------------
      Url: https://github.com/julianhyde/optiq/issues/226
      Created by: vlsi
      Labels:
      Created at: Wed Apr 02 21:36:53 CEST 2014
      State: closed

      Attachments

        Activity

          People

            Unassigned Unassigned
            github-import GitHub Import
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: