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

In JDBC adapter, do not push down a call to a user-defined function (UDF)

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.17.0
    • Component/s: jdbc-adapter
    • Labels:
      None

      Description

      Considering chinook tests, having following schema:

       {
        "version": "1.0",
        "defaultSchema": "ENHANCED",
        "schemas": [
          {
            "name": "CHINOOK",
            "type": "jdbc",
            "jdbcDriver": "org.hsqldb.jdbc.JDBCDriver",
            "jdbcUrl": "jdbc:hsqldb:res:chinook",
            "jdbcUser": "sa",
            "jdbcPassword": ""
          },
          {
            "name": "ENHANCED",
            "type": "custom",
            "factory": "org.apache.calcite.schema.impl.AbstractSchema$Factory",
            "operand": {},
            "tables": [
        ...
              {
                "name" : "SIMPLE_CUSTOMER",
                "type" : "view",
                "sql" : [
                  "SELECT c.firstname, c.lastname, c.email ",
                  "FROM chinook.customer AS c"
                ]
      ...
            ],
            "functions": [
              {
                "name": "ASCONCATOFPARAMS",
                "className": "org.apache.calcite.chinook.StringConcatFunction"
              }
            ]
          }
        ]
      

      Following query produces error:

      SELECT email, ASCONCATOFPARAMS(firstname, lastname) AS joined FROM SIMPLE_CUSTOMER limit 3
      

      Exception:

      > Caused by: java.lang.RuntimeException: while executing SQL [SELECT "EMAIL" AS "email", "ASCONCATOFPARAMS"("FIRSTNAME", "LASTNAME") AS "joined"
      > FROM (SELECT *
      > FROM "CUSTOMER"
      > LIMIT 3) AS "t"]
      > 	at org.apache.calcite.runtime.ResultSetEnumerable.enumerator(ResultSetEnumerable.java:153)
      > 	at org.apache.calcite.linq4j.AbstractEnumerable.iterator(AbstractEnumerable.java:33)
      > 	at org.apache.calcite.avatica.MetaImpl.createCursor(MetaImpl.java:90)
      > 	at org.apache.calcite.avatica.AvaticaResultSet.execute(AvaticaResultSet.java:174)
      > 	at org.apache.calcite.jdbc.CalciteResultSet.execute(CalciteResultSet.java:67)
      > 	at org.apache.calcite.jdbc.CalciteResultSet.execute(CalciteResultSet.java:44)
      > 	at org.apache.calcite.avatica.AvaticaConnection$1.execute(AvaticaConnection.java:630)
      > 	at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:619)
      > 	at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:638)
      > 	at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:149)
      > 	... 24 more
      > Caused by: java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: ASCONCATOFPARAMS
      > 	at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
      > 	at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
      > 	at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source)
      > 	at org.hsqldb.jdbc.JDBCStatement.execute(Unknown Source)
      > 	at org.apache.commons.dbcp.DelegatingStatement.execute(DelegatingStatement.java:264)
      > 	at org.apache.commons.dbcp.DelegatingStatement.execute(DelegatingStatement.java:264)
      > 	at org.apache.calcite.runtime.ResultSetEnumerable.enumerator(ResultSetEnumerable.java:143)
      > 	... 33 more
      > Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: ASCONCATOFPARAMS
      > 	at org.hsqldb.error.Error.error(Unknown Source)
      > 	at org.hsqldb.error.Error.error(Unknown Source)
      > 	at org.hsqldb.Routine.getMethods(Unknown Source)
      > 	at org.hsqldb.Routine.createRoutines(Unknown Source)
      > 	at org.hsqldb.ParserDQL.readColumnOrFunctionExpression(Unknown Source)
      > 	at org.hsqldb.ParserDQL.XreadSimpleValueExpressionPrimary(Unknown Source)
      > 	at org.hsqldb.ParserDQL.XreadAllTypesValueExpressionPrimary(Unknown Source)
      > 	at org.hsqldb.ParserDQL.XreadAllTypesPrimary(Unknown Source)
      > 	at org.hsqldb.ParserDQL.XreadAllTypesFactor(Unknown Source)
      > 	at org.hsqldb.ParserDQL.XreadAllTypesTerm(Unknown Source)
      > 	at org.hsqldb.ParserDQL.XreadAllTypesCommonValueExpression(Unknown Source)
      > 	at org.hsqldb.ParserDQL.XreadValueExpression(Unknown Source)
      > 	at org.hsqldb.ParserDQL.XreadSelect(Unknown Source)
      > 	at org.hsqldb.ParserDQL.XreadQuerySpecification(Unknown Source)
      > 	at org.hsqldb.ParserDQL.XreadSimpleTable(Unknown Source)
      > 	at org.hsqldb.ParserDQL.XreadQueryPrimary(Unknown Source)
      > 	at org.hsqldb.ParserDQL.XreadQueryTerm(Unknown Source)
      > 	at org.hsqldb.ParserDQL.XreadQueryExpressionBody(Unknown Source)
      > 	at org.hsqldb.ParserDQL.XreadQueryExpression(Unknown Source)
      > 	at org.hsqldb.ParserDQL.compileCursorSpecification(Unknown Source)
      > 	at org.hsqldb.ParserCommand.compilePart(Unknown Source)
      > 	at org.hsqldb.ParserCommand.compileStatements(Unknown Source)
      > 	at org.hsqldb.Session.executeDirectStatement(Unknown Source)
      > 	at org.hsqldb.Session.execute(Unknown Source)
      > 	... 38 more
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                julianhyde Julian Hyde
                Reporter:
                ptrbojko Piotr Bojko
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: