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.