Search in sources :

Example 6 with JoinPredicate

use of org.teiid.query.sql.lang.JoinPredicate in project teiid by teiid.

the class TestJoinPredicate method testNonEquivalence3.

/**
 * Test a <code>JoinPredicate</code> object using <code>UnitTestUtil.helpTestEquivalence</code>.
 * <p>
 * This test ensures that two different <code>JoinPredicate</code> objects
 * constructed with different join types but with the same criteria evaluate
 * as not equal.
 * <p>
 * For example:
 * ... m.g1 LEFT OUTER JOIN m.g2 ON m.g1.e1 = m.g2.e1
 * ... m.g1 RIGHT OUTER JOIN m.g2 ON m.g1.e2 = m.g2.e2
 */
public void testNonEquivalence3() {
    // $NON-NLS-1$
    JoinPredicate jp1 = example(JoinType.JOIN_LEFT_OUTER, "e1");
    // $NON-NLS-1$
    JoinPredicate jp2 = example(JoinType.JOIN_RIGHT_OUTER, "e1");
    int equals = -1;
    UnitTestUtil.helpTestEquivalence(equals, jp1, jp2);
}
Also used : JoinPredicate(org.teiid.query.sql.lang.JoinPredicate)

Example 7 with JoinPredicate

use of org.teiid.query.sql.lang.JoinPredicate in project teiid by teiid.

the class TestJoinImpl method helpExample.

public static JoinPredicate helpExample(JoinType type) {
    // $NON-NLS-1$ //$NON-NLS-2$
    ElementSymbol e1 = TestElementImpl.helpExample("vm1.g1", "e1");
    // $NON-NLS-1$ //$NON-NLS-2$
    ElementSymbol e2 = TestElementImpl.helpExample("vm1.g2", "e1");
    ArrayList criteria = new ArrayList();
    criteria.add(new CompareCriteria(e1, CompareCriteria.EQ, e2));
    return new JoinPredicate(new UnaryFromClause(e1.getGroupSymbol()), new UnaryFromClause(e2.getGroupSymbol()), type, criteria);
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) UnaryFromClause(org.teiid.query.sql.lang.UnaryFromClause) JoinPredicate(org.teiid.query.sql.lang.JoinPredicate) ArrayList(java.util.ArrayList) CompareCriteria(org.teiid.query.sql.lang.CompareCriteria)

Example 8 with JoinPredicate

use of org.teiid.query.sql.lang.JoinPredicate in project teiid by teiid.

the class TestGroupCollectorVisitor method testJoinPredicate1.

public void testJoinPredicate1() {
    GroupSymbol gs1 = exampleGroupSymbol(1);
    GroupSymbol gs2 = exampleGroupSymbol(2);
    JoinPredicate jp = new JoinPredicate(new UnaryFromClause(gs1), new UnaryFromClause(gs2), JoinType.JOIN_CROSS);
    Set groups = new HashSet();
    groups.add(gs1);
    groups.add(gs2);
    helpTestGroups(jp, true, groups);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) UnaryFromClause(org.teiid.query.sql.lang.UnaryFromClause) JoinPredicate(org.teiid.query.sql.lang.JoinPredicate) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) HashSet(java.util.HashSet)

Example 9 with JoinPredicate

use of org.teiid.query.sql.lang.JoinPredicate in project teiid by teiid.

the class TestGroupCollectorVisitor method testJoinPredicate2.

public void testJoinPredicate2() {
    GroupSymbol gs1 = exampleGroupSymbol(1);
    GroupSymbol gs2 = exampleGroupSymbol(2);
    GroupSymbol gs3 = exampleGroupSymbol(3);
    JoinPredicate jp1 = new JoinPredicate(new UnaryFromClause(gs1), new UnaryFromClause(gs2), JoinType.JOIN_CROSS);
    JoinPredicate jp2 = new JoinPredicate(new UnaryFromClause(gs3), jp1, JoinType.JOIN_CROSS);
    Set groups = new HashSet();
    groups.add(gs1);
    groups.add(gs2);
    groups.add(gs3);
    helpTestGroups(jp2, true, groups);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) UnaryFromClause(org.teiid.query.sql.lang.UnaryFromClause) JoinPredicate(org.teiid.query.sql.lang.JoinPredicate) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) HashSet(java.util.HashSet)

Example 10 with JoinPredicate

use of org.teiid.query.sql.lang.JoinPredicate in project teiid by teiid.

the class TestJoinPredicate method testEquivalence.

/**
 * Test a <code>JoinPredicate</code> object using <code>UnitTestUtil.helpTestEquivalence</code>.
 * <p>
 * This test ensures that two different <code>JoinPredicate</code> objects
 * constructed with the same join type and the same criteria evaluates as
 * equal.
 * <p>
 * For example:
 * ... m.g1 FULL OUTER JOIN m.g2 ON m.g1.e1 = m.g2.e1
 * ... m.g1 FULL OUTER JOIN m.g2 ON m.g1.e1 = m.g2.e1
 */
public void testEquivalence() {
    // $NON-NLS-1$
    JoinPredicate jp1 = example(JoinType.JOIN_FULL_OUTER, "e1");
    // $NON-NLS-1$
    JoinPredicate jp2 = example(JoinType.JOIN_FULL_OUTER, "e1");
    int equals = 0;
    UnitTestUtil.helpTestEquivalence(equals, jp1, jp2);
}
Also used : JoinPredicate(org.teiid.query.sql.lang.JoinPredicate)

Aggregations

JoinPredicate (org.teiid.query.sql.lang.JoinPredicate)15 UnaryFromClause (org.teiid.query.sql.lang.UnaryFromClause)4 HashSet (java.util.HashSet)2 Set (java.util.Set)2 CompareCriteria (org.teiid.query.sql.lang.CompareCriteria)2 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)2 ArrayList (java.util.ArrayList)1 CompoundCriteria (org.teiid.query.sql.lang.CompoundCriteria)1 Criteria (org.teiid.query.sql.lang.Criteria)1 FromClause (org.teiid.query.sql.lang.FromClause)1 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)1