Class Planner


  • public class Planner
    extends java.lang.Object
    Various methods for forming query plans on SQL queries.
    • Field Detail

      • GROUP_BY_FUNCTION_TABLE

        private static TableName GROUP_BY_FUNCTION_TABLE
        The name of the GROUP BY function table.
      • marker_randomizer

        private static java.util.Random marker_randomizer
        Used to generate unique marker names.
    • Constructor Detail

      • Planner

        public Planner()
    • Method Detail

      • createRandomeOuterJoinName

        private static java.lang.String createRandomeOuterJoinName()
        Returns a randomly generated outer join name.
      • prepareSearchExpression

        private static void prepareSearchExpression​(DatabaseConnection db,
                                                    TableExpressionFromSet from_set,
                                                    SearchExpression expression)
                                             throws DatabaseException
        Prepares the given SearchExpression object. This goes through each element of the Expression. If the element is a variable it is qualified. If the element is a TableSelectExpression it's converted to a SelectQueriable object and prepared.
        Throws:
        DatabaseException
      • filterHavingClause

        private static Expression filterHavingClause​(Expression having_expr,
                                                     java.util.ArrayList aggregate_list,
                                                     QueryContext context)
        Given a HAVING clause expression, this will generate a new HAVING clause expression with all aggregate expressions put into the given extra function list.
      • formQueryPlan

        public static QueryPlanNode formQueryPlan​(DatabaseConnection db,
                                                  TableSelectExpression expression,
                                                  TableExpressionFromSet from_set,
                                                  java.util.ArrayList order_by)
                                           throws DatabaseException
        Forms a query plan (QueryPlanNode) from the given TableSelectExpression and TableExpressionFromSet. The TableSelectExpression describes the SELECT query (or sub-query), and the TableExpressionFromSet is used to resolve expression references.

        The 'order_by' argument is a list of ByColumn objects that represent an optional ORDER BY clause. If this is null or the list is empty, no ordering is done.

        Throws:
        DatabaseException
      • substituteAliasedVariables

        private static void substituteAliasedVariables​(Expression expression,
                                                       java.util.ArrayList s_col_list)
        Substitutes any aliased variables in the given expression with the function name equivalent. For example, if we have a 'SELECT 3 + 4 Bah' then resolving on variable Bah will be subsituted to the function column that represents the result of 3 + 4.
      • substituteAliasedVariable

        private static void substituteAliasedVariable​(Variable v,
                                                      java.util.ArrayList s_col_list)