Class SqlParameterizerShuttle

java.lang.Object
org.apache.calcite.sql.util.SqlBasicVisitor<org.apache.calcite.sql.SqlNode>
org.apache.calcite.sql.util.SqlShuttle
org.apache.druid.sql.calcite.planner.SqlParameterizerShuttle
All Implemented Interfaces:
org.apache.calcite.sql.util.SqlVisitor<org.apache.calcite.sql.SqlNode>

public class SqlParameterizerShuttle extends org.apache.calcite.sql.util.SqlShuttle
Replaces all SqlDynamicParam encountered in an SqlNode tree with a SqlLiteral if a value binding exists for the parameter, if possible. This is used in tandem with RelParameterizerShuttle.

It is preferable that all parameters are placed here to pick up as many optimizations as possible, but the facilities to convert jdbc types to SqlLiteral are a bit less rich here than exist for converting a RexDynamicParam to RexLiteral, which is why SqlParameterizerShuttle and RelParameterizerShuttle both exist.

As it turns out, most parameters will be replaced in this shuttle. The one exception are DATE types expressed as integers. For reasons known only to Calcite, the RexBuilder.clean() method, used by RelParameterizerShuttle, handles integer values for dates, but the SqlTypeName.createLiteral() method used here does not. As a result, DATE parameters will be left as parameters to be filled in later. Fortunately, this does not affect optimizations as there are no rules that optimize based on the value of a DATE.

  • Nested Class Summary

    Nested classes/interfaces inherited from class org.apache.calcite.sql.util.SqlShuttle

    org.apache.calcite.sql.util.SqlShuttle.CallCopyingArgHandler

    Nested classes/interfaces inherited from class org.apache.calcite.sql.util.SqlBasicVisitor

    org.apache.calcite.sql.util.SqlBasicVisitor.ArgHandler<R extends Object>, org.apache.calcite.sql.util.SqlBasicVisitor.ArgHandlerImpl<R extends Object>
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.calcite.sql.SqlNode
    visit(org.apache.calcite.sql.SqlDynamicParam param)
     

    Methods inherited from class org.apache.calcite.sql.util.SqlShuttle

    visit, visit, visit, visit, visit, visit

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.calcite.sql.util.SqlVisitor

    visitNode
  • Constructor Details

    • SqlParameterizerShuttle

      public SqlParameterizerShuttle(PlannerContext plannerContext)
  • Method Details

    • visit

      public org.apache.calcite.sql.SqlNode visit(org.apache.calcite.sql.SqlDynamicParam param)
      Specified by:
      visit in interface org.apache.calcite.sql.util.SqlVisitor<org.apache.calcite.sql.SqlNode>
      Overrides:
      visit in class org.apache.calcite.sql.util.SqlShuttle