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

Druid adapter: Substring operator converter does not handle non-constant literals correctly

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.16.0
    • 1.17.0
    • druid-adapter
    • None

    Description

      Query like the following

      SELECT substring(namespace, CAST(deleted AS INT), 4)
      FROM druid_table;
      

      will fail with

      java.lang.AssertionError: not a literal: $13
      	at org.apache.calcite.rex.RexLiteral.findValue(RexLiteral.java:963)
      	at org.apache.calcite.rex.RexLiteral.findValue(RexLiteral.java:955)
      	at org.apache.calcite.rex.RexLiteral.intValue(RexLiteral.java:938)
      	at org.apache.calcite.adapter.druid.SubstringOperatorConversion.toDruidExpression(SubstringOperatorConversion.java:46)
      	at org.apache.calcite.adapter.druid.DruidExpressions.toDruidExpression(DruidExpressions.java:120)
      	at org.apache.calcite.adapter.druid.DruidQuery.computeProjectAsScan(DruidQuery.java:746)
      	at org.apache.calcite.adapter.druid.DruidRules$DruidProjectRule.onMatch(DruidRules.java:308)
      	at org.apache.calcite.plan.AbstractRelOptPlanner.fireRule(AbstractRelOptPlanner.java:317)
      

      Druid Substring converter is assuming that index is always a constant literal, which is wrong.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            bslim Slim Bouguerra
            bslim Slim Bouguerra
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment