Examples of JoinType


Examples of org.teiid.query.sql.lang.JoinType

        boolean pushRuleRaiseNull = false;
       
        for (PlanNode node : NodeEditor.findAllNodes(plan, NodeConstants.Types.JOIN)) {
            List criteria = (List)node.getProperty(NodeConstants.Info.JOIN_CRITERIA);
                       
            JoinType joinType = (JoinType)node.getProperty(NodeConstants.Info.JOIN_TYPE);
           
            //criteria cannot be pushed out of a full outer join clause
            if (joinType == JoinType.JOIN_FULL_OUTER || joinType == JoinType.JOIN_CROSS) {
                continue;
            }
View Full Code Here

Examples of org.teiid.query.sql.lang.JoinType

            return false;
        }
       
        //visit join nodes in order
        if (node.getType() == NodeConstants.Types.JOIN) {
            JoinType jt = (JoinType)node.getProperty(NodeConstants.Info.JOIN_TYPE);
           
            if (jt == JoinType.JOIN_FULL_OUTER) {
                return visitChildern(node, criteriaInfo, changedTree, metadata);
            }
           
View Full Code Here

Examples of org.teiid.query.sql.lang.JoinType

     * @param joinNode
     * @param critNode
     * @return
     */
    private boolean handleJoinCriteria(PlanNode joinNode, PlanNode critNode, QueryMetadataInterface metadata) {
        JoinType jt = (JoinType)joinNode.getProperty(NodeConstants.Info.JOIN_TYPE);
       
        if (jt == JoinType.JOIN_CROSS || jt == JoinType.JOIN_INNER) {
            if (jt == JoinType.JOIN_CROSS) {
                joinNode.setProperty(NodeConstants.Info.JOIN_TYPE, JoinType.JOIN_INNER);
            }
            moveCriteriaIntoOnClause(critNode, joinNode);
        } else {
            JoinType optimized = JoinUtil.optimizeJoinType(critNode, joinNode, metadata);
           
            if (optimized == JoinType.JOIN_INNER) {
                moveCriteriaIntoOnClause(critNode, joinNode);
                return true; //return true since the join type has changed
            }
View Full Code Here

Examples of org.teiid.query.sql.lang.JoinType

          return currentNode;
        }
       
                // Check whether this criteria is on the inner side of an outer join. 
                // If so, can't push past the join
                JoinType jt = JoinUtil.getJoinTypePreventingCriteriaOptimization(currentNode, critNode);
               
                if(jt != null) {
                    //if we successfully optimized then this should no longer inhibit the criteria from being pushed
                    //since the criteria must then be on the outer side of an outer join or on either side of an inner join

                    JoinType optimized = JoinUtil.optimizeJoinType(critNode, currentNode, metadata);
                   
                    if (optimized == null || optimized.isOuter()) {
                        return currentNode;
                    }
                } 
           
                satisfyAccessPatterns(critNode, currentNode);
View Full Code Here

Examples of org.teiid.query.sql.lang.JoinType

     * @param sourceNode The access node being considered
     * @param analysisRecord TODO
     * @return True if valid for making dependent
     */
    boolean isValidJoin(PlanNode joinNode, PlanNode sourceNode, AnalysisRecord analysisRecord) {
        JoinType jtype = (JoinType) joinNode.getProperty(NodeConstants.Info.JOIN_TYPE);

        // Check that join is not a CROSS join or FULL OUTER join
        if(jtype.equals(JoinType.JOIN_CROSS) || jtype.equals(JoinType.JOIN_FULL_OUTER)) {
          if (analysisRecord.recordDebug()) {
            analysisRecord.println("Rejecting dependent access node as parent join is CROSS or FULL OUTER: "+ sourceNode.nodeToString()); //$NON-NLS-1$
          }
            return false;
        }
       
        if (!joinNode.getExportedCorrelatedReferences().isEmpty()) {
          if (analysisRecord.recordDebug()) {
            analysisRecord.println("Rejecting dependent access node as parent join has a correlated nested table: "+ sourceNode.nodeToString()); //$NON-NLS-1$
          }
          return false;
        }

        // Check that join criteria exist
        List jcrit = (List) joinNode.getProperty(NodeConstants.Info.JOIN_CRITERIA);
        if(jcrit == null || jcrit.size() == 0) {
          if (analysisRecord.recordDebug()) {
            analysisRecord.println("Rejecting dependent access node as parent join has no join criteria: "+ sourceNode.nodeToString()); //$NON-NLS-1$
          }
            return false;
        }
       
        if(joinNode.getProperty(NodeConstants.Info.LEFT_EXPRESSIONS) == null) {
          if (analysisRecord.recordDebug()) {
            analysisRecord.println("Rejecting dependent access node as parent join has no equality expressions: "+ sourceNode.nodeToString()); //$NON-NLS-1$
          }
            return false;
        }
                       
        // Check that for a left or right outer join the dependent side must be the inner
        if(jtype.isOuter() && JoinUtil.getInnerSideJoinNodes(joinNode)[0] != sourceNode) {
          if (analysisRecord.recordDebug()) {
            analysisRecord.println("Rejecting dependent access node as it is on outer side of a join: "+ sourceNode.nodeToString()); //$NON-NLS-1$
          }
            return false;
        }
View Full Code Here

Examples of org.teiid.query.sql.lang.JoinType

        PlanNode parentNode = nullNode.getParent();
       
        switch(parentNode.getType()) {
            case NodeConstants.Types.JOIN:
            {
                JoinType jt = (JoinType)parentNode.getProperty(NodeConstants.Info.JOIN_TYPE);
                if (jt == JoinType.JOIN_CROSS || jt == JoinType.JOIN_INNER) {
                    return raiseNullNode(rootNode, parentNode, nullNode, nodes);
                }
                //for outer joins if the null node is on the outer side, then the join itself is null
                //if the null node is on the inner side, then the join can be removed but the null values
View Full Code Here

Examples of org.teiid.query.sql.lang.JoinType

            return null;
          }
        }
        }
        }
        JoinType jt = (JoinType)joinNode.getProperty(NodeConstants.Info.JOIN_TYPE);
       
        if (!isOptional &&
            (jt != JoinType.JOIN_LEFT_OUTER || optionalNode != joinNode.getLastChild() || useNonDistinctRows(joinNode.getParent()))) {
          return null;
        }
      // remove the parent node and move the sibling node upward
    PlanNode parentNode = joinNode.getParent();
    joinNode.removeChild(optionalNode);
    joinNode.getFirstChild().setProperty(NodeConstants.Info.OUTPUT_COLS, joinNode.getProperty(NodeConstants.Info.OUTPUT_COLS));
    NodeEditor.removeChildNode(parentNode, joinNode);
    if (record != null && record.recordDebug()) {
      record.println("Removing join node since " + (isOptional?"it was marked as optional ":"it will not affect the results") + joinNode); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }

    while (parentNode.getType() != NodeConstants.Types.PROJECT) {
      PlanNode current = parentNode;
      parentNode = parentNode.getParent();
      if (correctFrame) {
        if (current.getType() == NodeConstants.Types.SELECT) {
          if (!Collections.disjoint(current.getGroups(), optionalNode.getGroups())) {
            current.getFirstChild().setProperty(NodeConstants.Info.OUTPUT_COLS, current.getProperty(NodeConstants.Info.OUTPUT_COLS));
            NodeEditor.removeChildNode(parentNode, current);
          }
        } else if (current.getType() == NodeConstants.Types.JOIN) {
          if (!Collections.disjoint(current.getGroups(), optionalNode.getGroups())) {
            List<Criteria> crits = (List<Criteria>) current.getProperty(NodeConstants.Info.JOIN_CRITERIA);
            if (crits != null && !crits.isEmpty()) {
              for (Iterator<Criteria> iterator = crits.iterator(); iterator.hasNext();) {
                Criteria criteria = iterator.next();
                if (!Collections.disjoint(GroupsUsedByElementsVisitor.getGroups(criteria), optionalNode.getGroups())) {
                  iterator.remove();
                }
              }
              if (crits.isEmpty()) {
                JoinType joinType = (JoinType) current.getProperty(NodeConstants.Info.JOIN_TYPE);
                if (joinType == JoinType.JOIN_INNER) {
                  current.setProperty(NodeConstants.Info.JOIN_TYPE, JoinType.JOIN_CROSS);
                }
              }
            }
View Full Code Here

Examples of org.teiid.query.sql.lang.JoinType

        if (childCost1 == UNKNOWN_VALUE || childCost2 == UNKNOWN_VALUE) {
          setCardinalityEstimate(node, null, true, metadata);
          return;
        }

        JoinType joinType = (JoinType)node.getProperty(NodeConstants.Info.JOIN_TYPE);
        List joinCriteria = (List) node.getProperty(NodeConstants.Info.JOIN_CRITERIA);
       
        float baseCost = childCost1 * childCost2;

        if (joinCriteria != null && !joinCriteria.isEmpty()) {
View Full Code Here

Examples of org.teiid.query.sql.lang.JoinType

    static final JoinType optimizeJoinType(PlanNode critNode, PlanNode joinNode, QueryMetadataInterface metadata) {
        if (critNode.getGroups().isEmpty() || !joinNode.getGroups().containsAll(critNode.getGroups())) {
            return null;
        }

        JoinType joinType = (JoinType) joinNode.getProperty(NodeConstants.Info.JOIN_TYPE);

        if (!joinType.isOuter()) {
            return null;
        }
       
        PlanNode left = joinNode.getFirstChild();
        left = FrameUtil.findJoinSourceNode(left);
        PlanNode right = joinNode.getLastChild();
        right = FrameUtil.findJoinSourceNode(right);
       
        Collection<GroupSymbol> outerGroups = left.getGroups();
        Collection<GroupSymbol> innerGroups = right.getGroups();
        if (joinType == JoinType.JOIN_RIGHT_OUTER) {
            outerGroups = innerGroups;
            innerGroups = left.getGroups();
        }
       
        //sanity check
        if ((joinType == JoinType.JOIN_LEFT_OUTER || joinType == JoinType.JOIN_RIGHT_OUTER)
                        && outerGroups.containsAll(critNode.getGroups())) {
            return null;
        }
       
        Criteria crit = (Criteria)critNode.getProperty(NodeConstants.Info.SELECT_CRITERIA);

        boolean isNullDepdendent = isNullDependent(metadata, innerGroups, crit);
       
        JoinType result = JoinType.JOIN_INNER;
       
        if (joinType == JoinType.JOIN_LEFT_OUTER || joinType == JoinType.JOIN_RIGHT_OUTER) {
            if (isNullDepdendent) {
                return null;
            }
View Full Code Here

Examples of org.teiid.query.sql.lang.JoinType

        return getJoinTypePreventingCriteriaOptimization(joinNode, groups);
    }

    public static JoinType getJoinTypePreventingCriteriaOptimization(PlanNode joinNode,
                                                                      Set<GroupSymbol> groups) {
        JoinType joinType = (JoinType) joinNode.getProperty(NodeConstants.Info.JOIN_TYPE);

        if(!joinType.isOuter()) {
            return null;
        }
       
        if(joinType.equals(JoinType.JOIN_FULL_OUTER)) {
            return joinType;
        }
       
        Set<GroupSymbol> innerGroups = getInnerSideJoinNodes(joinNode)[0].getGroups();
        for (GroupSymbol group : groups) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.