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

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.16.0
    • Fix Version/s: 1.17.0
    • Component/s: druid
    • Labels:
      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

              People

              • Assignee:
                bslim slim bouguerra
                Reporter:
                bslim slim bouguerra
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: