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

UDF in WHERE expression incorrectly pushed down to jdbc schema

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.16.0, 1.17.0
    • Fix Version/s: 1.17.0
    • Component/s: None
    • Labels:
      None

      Description

      1. Checks whether CHOOSENCUSTOMFUNCTION function is properly computed and not passed to subschema, like jdbc
        SELECT * FROM SIMPLE_CUSTOMER WHERE email = CHOOSENCUSTOMER();

      where CHOOSENCUSTOMER is UDF leads to

       Caused by: java.lang.RuntimeException: while executing SQL [SELECT "FIRSTNAME", "LASTNAME", "EMAIL"
      > FROM "CUSTOMER"
      > WHERE "EMAIL" = "CHOOSENCUSTOMER"()]
      > 	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: CHOOSENCUSTOMER
      > 	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: CHOOSENCUSTOMER
      > 	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.XreadRowOrCommonValueExpression(Unknown Source)
      > 	at org.hsqldb.ParserDQL.XreadRowValuePredicand(Unknown Source)
      > 	at org.hsqldb.ParserDQL.XreadPredicateRightPart(Unknown Source)
      > 	at org.hsqldb.ParserDQL.XreadBooleanPrimaryOrNull(Unknown Source)
      

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: