Class SplitterQueryModel


  • public final class SplitterQueryModel
    extends Object
    Simplified tree-like model for a query. - SELECT : All the children are list of joined query models in the FROM clause. - UNION : All the children are united left and right query models. - TABLE and FUNCTION : Never have child models.
    • Constructor Detail

      • SplitterQueryModel

        public SplitterQueryModel​(SplitterQueryModelType type,
                                  GridSqlAst parent,
                                  int childIdx,
                                  GridSqlAlias uniqueAlias)
        Constructor (no split).
        Parameters:
        type - Type.
        parent - Parent element.
        childIdx - Child index.
        uniqueAlias - Unique parent alias of the current element. May be null for selects inside of unions or top level queries.
      • SplitterQueryModel

        public SplitterQueryModel​(SplitterQueryModelType type,
                                  GridSqlAst parent,
                                  int childIdx,
                                  GridSqlAlias uniqueAlias,
                                  boolean needSplit)
        Constructor.
        Parameters:
        type - Type.
        parent - Parent element.
        childIdx - Child index.
        uniqueAlias - Unique parent alias of the current element. May be null for selects inside of unions or top level queries.
        needSplit - Need split flag.
    • Method Detail

      • isQuery

        public boolean isQuery()
        Returns:
        true If this is a SELECT or UNION query model.
      • uniqueAlias

        public GridSqlAlias uniqueAlias()
        Returns:
        Unique alias.
      • parent

        public GridSqlAst parent()
        Returns:
        Parent AST element.
      • childIndex

        public int childIndex()
        Returns:
        Child index.
      • ast

        public <X extends GridSqlAst> X ast()
        Returns:
        The actual AST element for this model.
      • needSplit

        public boolean needSplit()
        Returns:
        Whether split is needed.
      • needSplitChild

        public boolean needSplitChild()
        Returns:
        Whether split of children is needed.
      • moveChildModelsToWrapModel

        public void moveChildModelsToWrapModel​(SplitterQueryModel wrapModel,
                                               int begin,
                                               int end)
        Move child models to wrap model.
        Parameters:
        wrapModel - Wrap model.
        begin - Child begin index.
        end - Child end index.
      • forceSplit

        public void forceSplit()
        Force split flag on a model.
      • unionAll

        public void unionAll​(boolean unionAll)
        Parameters:
        unionAll - UNION ALL flag.
      • childModelsCount

        public int childModelsCount()
        Returns:
        Number of child models.
      • childModel

        public SplitterQueryModel childModel​(int idx)
        Get child model by index.
        Parameters:
        idx - Index.
        Returns:
        Child model.
      • buildQueryModel

        public void buildQueryModel​(GridSqlAst prnt,
                                    int childIdx,
                                    GridSqlAlias uniqueAlias)
        Prepare query model.
        Parameters:
        prnt - Parent AST element.
        childIdx - Child index.
        uniqueAlias - Unique parent alias of the current element.
      • analyzeQueryModel

        public void analyzeQueryModel​(boolean collocatedGrpBy)
        Analyze query model, setting split flags as needed.
        Parameters:
        collocatedGrpBy - Collocated GROUP BY flag.
      • findJoin

        public GridSqlJoin findJoin​(int idx)
        Parameters:
        idx - Index of the child model for which we need to find a respective JOIN element.
        Returns:
        JOIN.