Class SqlDynamicParam

  • All Implemented Interfaces:

    public class SqlDynamicParam
    extends SqlNode
    A SqlDynamicParam represents a dynamic parameter marker in an SQL statement. The textual order in which dynamic parameters appear within an SQL statement is the only property which distinguishes them, so this 0-based index is recorded as soon as the parameter is encountered.
    • Field Detail

      • index

        private final int index
    • Constructor Detail

      • SqlDynamicParam

        public SqlDynamicParam​(int index,
                               SqlParserPos pos)
    • Method Detail

      • getIndex

        public int getIndex()
      • unparse

        public void unparse​(SqlWriter writer,
                            int leftPrec,
                            int rightPrec)
        Description copied from class: SqlNode
        Writes a SQL representation of this node to a writer.

        The leftPrec and rightPrec parameters give us enough context to decide whether we need to enclose the expression in parentheses. For example, we need parentheses around "2 + 3" if preceded by "5 *". This is because the precedence of the "*" operator is greater than the precedence of the "+" operator.

        The algorithm handles left- and right-associative operators by giving them slightly different left- and right-precedence.

        If SqlWriter.isAlwaysUseParentheses() is true, we use parentheses even when they are not required by the precedence rules.

        For the details of this algorithm, see SqlCall.unparse(org.apache.calcite.sql.SqlWriter, int, int).

        Specified by:
        unparse in class SqlNode
        writer - Target writer
        leftPrec - The precedence of the SqlNode immediately preceding this node in a depth-first scan of the parse tree
        rightPrec - The precedence of the SqlNode immediately
      • accept

        public <R> R accept​(SqlVisitor<R> visitor)
        Description copied from class: SqlNode
        Accepts a generic visitor.

        Implementations of this method in subtypes simply call the appropriate visit method on the visitor object.

        The type parameter R must be consistent with the type parameter of the visitor.

        Specified by:
        accept in class SqlNode
      • equalsDeep

        public boolean equalsDeep​(SqlNode node,
                                  Litmus litmus)
        Description copied from class: SqlNode
        Returns whether this node is structurally equivalent to another node. Some examples:
        • 1 + 2 is structurally equivalent to 1 + 2
        • 1 + 2 + 3 is structurally equivalent to (1 + 2) + 3, but not to 1 + (2 + 3), because the '+' operator is left-associative
        Specified by:
        equalsDeep in class SqlNode