Examples of JoinPredicate


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

      if (!metadata.getUniqueKeysInGroup(ufc.getGroup().getMetadataID()).isEmpty()) {
        keyPreservingGroups.add(ufc.getGroup());
      }
    }
    if (clause instanceof JoinPredicate) {
      JoinPredicate jp = (JoinPredicate)clause;
      if (jp.getJoinType() == JoinType.JOIN_CROSS || jp.getJoinType() == JoinType.JOIN_FULL_OUTER) {
        return;
      }
      HashSet<GroupSymbol> leftPk = new HashSet<GroupSymbol>();
      findKeyPreserved(jp.getLeftClause(), leftPk, metadata);
      HashSet<GroupSymbol> rightPk = new HashSet<GroupSymbol>();
      findKeyPreserved(jp.getRightClause(), rightPk, metadata);
     
      if (leftPk.isEmpty() && rightPk.isEmpty()) {
        return;
      }
     
      HashSet<GroupSymbol> leftGroups = new HashSet<GroupSymbol>();
      HashSet<GroupSymbol> rightGroups = new HashSet<GroupSymbol>();
      jp.getLeftClause().collectGroups(leftGroups);
      jp.getRightClause().collectGroups(rightGroups);
     
      LinkedList<Expression> leftExpressions = new LinkedList<Expression>();
      LinkedList<Expression> rightExpressions = new LinkedList<Expression>();
      RuleChooseJoinStrategy.separateCriteria(leftGroups, rightGroups, leftExpressions, rightExpressions, jp.getJoinCriteria(), new LinkedList<Criteria>());
       
      HashMap<List<GroupSymbol>, List<HashSet<Object>>> crits = createGroupMap(leftExpressions, rightExpressions);
      if (!leftPk.isEmpty() && (jp.getJoinType() == JoinType.JOIN_INNER || jp.getJoinType() == JoinType.JOIN_LEFT_OUTER)) {
        findKeyPreserved(keyPreservingGroups, leftPk, crits, true, metadata, rightPk);
      }
      if (!rightPk.isEmpty() && (jp.getJoinType() == JoinType.JOIN_INNER || jp.getJoinType() == JoinType.JOIN_RIGHT_OUTER)) {
        findKeyPreserved(keyPreservingGroups, rightPk, crits, false, metadata, leftPk);
      }
    }
  }
View Full Code Here

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

        List clauses = from.getClauses();
       
        while (clauses.size() > 1) {
            FromClause first = (FromClause)from.getClauses().remove(0);
            FromClause second = (FromClause)from.getClauses().remove(0);
            JoinPredicate jp = new JoinPredicate(first, second, JoinType.JOIN_CROSS);
            clauses.add(0, jp);
        }
       
        return (FromClause)clauses.get(0);
    }
View Full Code Here

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

              }
              addNestedCommand(node, group, nestedCommand, nestedCommand, true);
            }
            parent.addLastChild(node);
        } else if(clause instanceof JoinPredicate) {
            JoinPredicate jp = (JoinPredicate) clause;

            // Set up new join node corresponding to this join predicate
            node = NodeFactory.getNewNode(NodeConstants.Types.JOIN);
            node.setProperty(NodeConstants.Info.JOIN_TYPE, jp.getJoinType());
            node.setProperty(NodeConstants.Info.JOIN_STRATEGY, JoinStrategyType.NESTED_LOOP);
            node.setProperty(NodeConstants.Info.JOIN_CRITERIA, jp.getJoinCriteria());
           
            if (jp.getJoinType() == JoinType.JOIN_LEFT_OUTER) {
              hints.hasOptionalJoin = true;
            }
        
            // Attach join node to parent
            parent.addLastChild(node);

            // Handle each child
            FromClause[] clauses = new FromClause[] {jp.getLeftClause(), jp.getRightClause()};
            for(int i=0; i<2; i++) {
                buildTree(clauses[i], node);

                // Add groups to joinNode
                for (PlanNode child : node.getChildren()) {
View Full Code Here

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

            addDiscoveredGroups();
        }

    private void checkImplicit(FromClause clause) {
      if (clause instanceof JoinPredicate) {
        JoinPredicate jp = (JoinPredicate)clause;
        if (jp.getJoinType() == JoinType.JOIN_FULL_OUTER || jp.getJoinType() == JoinType.JOIN_RIGHT_OUTER) {
          allowImplicit = false;
          return;
        }
        checkImplicit(jp.getLeftClause());
        if (allowImplicit) {
          checkImplicit(jp.getRightClause());
        }
      }
    }
View Full Code Here

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

    }
   
    public void testFrom2() {
      From from = new From();
      from.addClause(new UnaryFromClause(new GroupSymbol("m.g1")));   //$NON-NLS-1$
      from.addClause(new JoinPredicate(
        new UnaryFromClause(new GroupSymbol("m.g2")), //$NON-NLS-1$
        new UnaryFromClause(new GroupSymbol("m.g3"))//$NON-NLS-1$
        JoinType.JOIN_CROSS) );
     
      helpTest(from, "FROM m.g1, m.g2 CROSS JOIN m.g3");     //$NON-NLS-1$
View Full Code Here

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

        inc.setNegated(true);
        helpTest(inc, "m.g.e1 IS NOT NULL"); //$NON-NLS-1$
    }

  public void testJoinPredicate1() {
    JoinPredicate jp = new JoinPredicate(
        new UnaryFromClause(new GroupSymbol("m.g2")), //$NON-NLS-1$
        new UnaryFromClause(new GroupSymbol("m.g3"))//$NON-NLS-1$
        JoinType.JOIN_CROSS);
       
      helpTest(jp, "m.g2 CROSS JOIN m.g3"); //$NON-NLS-1$
View Full Code Here

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

       
      helpTest(jp, "m.g2 CROSS JOIN m.g3"); //$NON-NLS-1$
  }
   
    public void testOptionalJoinPredicate1() {
        JoinPredicate jp = new JoinPredicate(
            new UnaryFromClause(new GroupSymbol("m.g2")), //$NON-NLS-1$
            new UnaryFromClause(new GroupSymbol("m.g3"))//$NON-NLS-1$
            JoinType.JOIN_CROSS);
        jp.setOptional(true);
        helpTest(jp, "/*+ optional */ (m.g2 CROSS JOIN m.g3)"); //$NON-NLS-1$
    }
View Full Code Here

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

    }

  public void testJoinPredicate2() {
      ArrayList<Criteria> crits = new ArrayList<Criteria>();
      crits.add(new CompareCriteria(new ElementSymbol("m.g2.e1"), CompareCriteria.EQ, new ElementSymbol("m.g3.e1"))); //$NON-NLS-1$ //$NON-NLS-2$
    JoinPredicate jp = new JoinPredicate(
        new UnaryFromClause(new GroupSymbol("m.g2")), //$NON-NLS-1$
        new UnaryFromClause(new GroupSymbol("m.g3")), //$NON-NLS-1$
        JoinType.JOIN_INNER,
        crits );
       
View Full Code Here

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

 
  public void testJoinPredicate3() {
      ArrayList<Criteria> crits = new ArrayList<Criteria>();
      crits.add(new CompareCriteria(new ElementSymbol("m.g2.e1"), CompareCriteria.EQ, new ElementSymbol("m.g3.e1"))); //$NON-NLS-1$ //$NON-NLS-2$
      crits.add(new CompareCriteria(new ElementSymbol("m.g2.e2"), CompareCriteria.EQ, new ElementSymbol("m.g3.e2"))); //$NON-NLS-1$ //$NON-NLS-2$
    JoinPredicate jp = new JoinPredicate(
        new UnaryFromClause(new GroupSymbol("m.g2")), //$NON-NLS-1$
        new UnaryFromClause(new GroupSymbol("m.g3")), //$NON-NLS-1$
        JoinType.JOIN_INNER,
        crits );
       
View Full Code Here

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

  }

  public void testJoinPredicate4() {
      ArrayList<Criteria> crits = new ArrayList<Criteria>();
      crits.add(new CompareCriteria(new ElementSymbol("m.g2.e1"), CompareCriteria.EQ, new ElementSymbol("m.g3.e1"))); //$NON-NLS-1$ //$NON-NLS-2$
    JoinPredicate jp = new JoinPredicate(
        new UnaryFromClause(new GroupSymbol("m.g2")), //$NON-NLS-1$
        new UnaryFromClause(new GroupSymbol("m.g3")), //$NON-NLS-1$
        JoinType.JOIN_INNER,
        crits );
       
      JoinPredicate jp2 = new JoinPredicate(
        jp,
        new UnaryFromClause(new GroupSymbol("m.g1")), //$NON-NLS-1$
        JoinType.JOIN_CROSS);
       
      helpTest(jp2, "(m.g2 INNER JOIN m.g3 ON m.g2.e1 = m.g3.e1) CROSS JOIN m.g1"); //$NON-NLS-1$
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.