Search in sources :

Example 11 with AccessNode

use of org.teiid.query.processor.relational.AccessNode in project teiid by teiid.

the class TestConformedTables method testConformedJoin.

@Test
public void testConformedJoin() throws Exception {
    String sql = "select pm1.g1.e1 from pm1.g1, pm2.g2 where g1.e1=g2.e1";
    RelationalPlan plan = (RelationalPlan) helpPlan(sql, tm, new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0, pm2.g2 AS g_1 WHERE g_0.e1 = g_1.e1" }, ComparisonMode.EXACT_COMMAND_STRING);
    AccessNode anode = (AccessNode) plan.getRootNode();
    assertEquals("pm2", anode.getModelName());
    // it should work either way
    sql = "select pm1.g1.e1 from pm2.g2, pm1.g1 where g1.e1=g2.e1";
    plan = (RelationalPlan) helpPlan(sql, tm, new String[] { "SELECT g_1.e1 FROM pm2.g2 AS g_0, pm1.g1 AS g_1 WHERE g_1.e1 = g_0.e1" }, ComparisonMode.EXACT_COMMAND_STRING);
    anode = (AccessNode) plan.getRootNode();
    assertEquals("pm2", anode.getModelName());
}
Also used : AccessNode(org.teiid.query.processor.relational.AccessNode) RelationalPlan(org.teiid.query.processor.relational.RelationalPlan) Test(org.junit.Test)

Example 12 with AccessNode

use of org.teiid.query.processor.relational.AccessNode in project teiid by teiid.

the class TestDependentJoins method getDependentGroups.

static void getDependentGroups(RelationalNode node, Set<String> depGroups, boolean depdenent) {
    if (node instanceof AccessNode) {
        if (node instanceof DependentAccessNode) {
            if (!depdenent) {
                return;
            }
        } else if (depdenent) {
            return;
        }
        AccessNode accessNode = (AccessNode) node;
        Command depCommand = accessNode.getCommand();
        Collection<GroupSymbol> groupSymbols = GroupCollectorVisitor.getGroups(depCommand, true);
        for (GroupSymbol groupSymbol : groupSymbols) {
            depGroups.add(groupSymbol.getNonCorrelationName().toUpperCase());
        }
    }
    // Recurse through children
    RelationalNode[] children = node.getChildren();
    for (int i = 0; i < children.length; i++) {
        if (children[i] != null) {
            getDependentGroups(node.getChildren()[i], depGroups, depdenent);
        }
    }
}
Also used : RelationalNode(org.teiid.query.processor.relational.RelationalNode) Command(org.teiid.query.sql.lang.Command) DependentAccessNode(org.teiid.query.processor.relational.DependentAccessNode) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) DependentAccessNode(org.teiid.query.processor.relational.DependentAccessNode) AccessNode(org.teiid.query.processor.relational.AccessNode)

Aggregations

AccessNode (org.teiid.query.processor.relational.AccessNode)12 RelationalPlan (org.teiid.query.processor.relational.RelationalPlan)8 RelationalNode (org.teiid.query.processor.relational.RelationalNode)4 LanguageObject (org.teiid.query.sql.LanguageObject)4 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)3 CreateProcedureCommand (org.teiid.query.sql.proc.CreateProcedureCommand)3 SymbolMap (org.teiid.query.sql.util.SymbolMap)3 QueryPlannerException (org.teiid.api.exception.query.QueryPlannerException)2 TeiidProcessingException (org.teiid.core.TeiidProcessingException)2 TempMetadataID (org.teiid.query.metadata.TempMetadataID)2 PlanNode (org.teiid.query.optimizer.relational.plantree.PlanNode)2 SubqueryAwareRelationalNode (org.teiid.query.processor.relational.SubqueryAwareRelationalNode)2 Command (org.teiid.query.sql.lang.Command)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Set (java.util.Set)1 Test (org.junit.Test)1 QueryMetadataException (org.teiid.api.exception.query.QueryMetadataException)1