Package org.teiid.query.processor.relational

Examples of org.teiid.query.processor.relational.RelationalPlan


    }
   
    @Test public void testLimitWithUnknownChildCardinality() throws Exception {
        String query = "select e1 from pm1.g1 limit 2"; //$NON-NLS-1$
       
        RelationalPlan plan = (RelationalPlan)TestOptimizer.helpPlan(query, FakeMetadataFactory.example1Cached(), new String[] {"SELECT e1 FROM pm1.g1"}); //$NON-NLS-1$
       
        assertEquals(new Float(2), plan.getRootNode().getEstimateNodeCardinality());
    }
View Full Code Here


        helpTestQuery(cost, query, expected);
    }

  private void helpTestQuery(float cost, String query, String[] expected)
      throws TeiidComponentException, TeiidProcessingException {
    RelationalPlan plan = (RelationalPlan)TestOptimizer.helpPlan(query, TestVirtualDepJoin.exampleVirtualDepJoin(), expected, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
       
        assertEquals(cost, plan.getRootNode().getEstimateNodeCardinality());
  }
View Full Code Here

                                        String inputCriteria,
                                        String atomicQuery) {
        ProcessorPlan plan = TestOptimizer.helpPlan(userQuery, FakeMetadataFactory.example1Cached(),
            new String[] {} );
       
        RelationalPlan rplan = (RelationalPlan)plan;

        RelationalNode root = rplan.getRootNode();
       
        while (root.getChildren() != null) {
            root = root.getChildren()[0];
           
            if (root instanceof DependentProcedureExecutionNode) {
View Full Code Here

  public static QueryCommand getQueryCommand(ProcessorPlan plan) {
    if(!(plan instanceof RelationalPlan)) {
        return null;
    }
               
    RelationalPlan rplan = (RelationalPlan) plan;
   
    // Check that the plan is just an access node               
    RelationalNode accessNode = rplan.getRootNode();
   
    if (accessNode instanceof LimitNode) {
      LimitNode ln = (LimitNode)accessNode;
      if (!ln.isImplicit()) {
        return null;
View Full Code Here

        context.setMetadata(metadata);
        ProcessorPlan plan = helpGetPlan(command, metadata, capFinder,context);
       
        //Verify a dependent join (not merge join) was used
        assertTrue(plan instanceof RelationalPlan);
        RelationalPlan relationalPlan = (RelationalPlan)plan;
        RelationalNode project = relationalPlan.getRootNode();
        RelationalNode join = project.getChildren()[0];
        assertTrue("Expected instance of JoinNode (for dep join) but got " + join.getClass(), join instanceof JoinNode); //$NON-NLS-1$

        // Run query
        helpProcess(plan, context, dataManager, expected);       
View Full Code Here

        context.setMetadata(metadata);
        ProcessorPlan plan = helpGetPlan(command, metadata, capFinder, context);
       
        //Verify a dependent join (not merge join) was used
        assertTrue(plan instanceof RelationalPlan);
        RelationalPlan relationalPlan = (RelationalPlan)plan;
        RelationalNode project = relationalPlan.getRootNode();
        RelationalNode join = project.getChildren()[0];
        assertTrue("Expected instance of JoinNode (for dep join) but got " + join.getClass(), join instanceof JoinNode); //$NON-NLS-1$

        // Run query
        helpProcess(plan, context, dataManager, expected);       
View Full Code Here

        prepareSubquery(container);
    }
  }

  public static void prepareSubquery(SubqueryContainer container) {
    RelationalPlan subqueryPlan = (RelationalPlan)container.getCommand().getProcessorPlan();
    QueryCommand command = CriteriaCapabilityValidatorVisitor.getQueryCommand(subqueryPlan);
    if (command == null) {
      return;
    }
    final SymbolMap map = container.getCommand().getCorrelatedReferences();
View Full Code Here

        && sourceCost < RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY && !plannedResult.mergeJoin) {
      //TODO: see if a dependent join applies the other direction
      return current;
    }
   
    RelationalPlan originalPlan = (RelationalPlan)plannedResult.query.getProcessorPlan();
        Number originalCardinality = originalPlan.getRootNode().getEstimateNodeCardinality();
        if (!plannedResult.mergeJoin && originalCardinality.floatValue() == NewCalculateCostUtil.UNKNOWN_VALUE) {
            //TODO: this check isn't really accurate - exists and scalarsubqueries will always have cardinality 2/1
          //if it's currently unknown, removing criteria won't make it any better
          return current;
        }
       
        Collection<GroupSymbol> leftGroups = FrameUtil.findJoinSourceNode(current).getGroups();

    if (!planQuery(leftGroups, false, plannedResult)) {
      if (plannedResult.mergeJoin && analysisRecord != null && analysisRecord.recordAnnotations()) {
        this.analysisRecord.addAnnotation(new Annotation(Annotation.HINTS, "could not plan as a merge join: " + crit, "ignoring hint", Priority.MEDIUM)); //$NON-NLS-1$ //$NON-NLS-2$
      }
      return current;
    }
   
    //add an order by, which hopefully will get pushed down
    plannedResult.query.setOrderBy(new OrderBy(plannedResult.rightExpressions).clone());
    for (OrderByItem item : plannedResult.query.getOrderBy().getOrderByItems()) {
      int index = plannedResult.query.getProjectedSymbols().indexOf(item.getSymbol());
      item.setExpressionPosition(index);
    }
   
    try {
      //clone the symbols as they may change during planning
      List<SingleElementSymbol> projectedSymbols = LanguageObject.Util.deepClone(plannedResult.query.getProjectedSymbols(), SingleElementSymbol.class);
      //NOTE: we could tap into the relationalplanner at a lower level to get this in a plan node form,
      //the major benefit would be to reuse the dependent join planning logic if possible.
      if (analysisRecord != null && analysisRecord.recordDebug()) {
        analysisRecord.println("Attempting to plan " + crit + " as a merge join"); //$NON-NLS-1$ //$NON-NLS-2$
      }
      RelationalPlan subPlan = (RelationalPlan)QueryOptimizer.optimizePlan(plannedResult.query, metadata, idGenerator, capFinder, analysisRecord, context);
      Number planCardinality = subPlan.getRootNode().getEstimateNodeCardinality();
           
      if (!plannedResult.mergeJoin) {
        //if we don't have a specific hint, then use costing
              if (planCardinality.floatValue() == NewCalculateCostUtil.UNKNOWN_VALUE
                  || planCardinality.floatValue() > 10000000
View Full Code Here

        caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
        caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
        caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
        capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$

        RelationalPlan plan = (RelationalPlan)helpPlan(sql, 
                                      FakeMetadataFactory.exampleBQTCached(),
                                      null, capFinder,
                                      new String[] {"SELECT bqt1.smalla.datevalue, bqt1.smalla.intkey, bqt1.smalla.stringkey, bqt1.smalla.objectvalue FROM bqt1.smalla WHERE (bqt1.smalla.intkey = 46) AND (bqt1.smalla.stringkey = '46')"}, //$NON-NLS-1$
                                      SHOULD_SUCCEED );

        checkNodeTypes(plan, new int[] {
                                        1,      // Access
                                        0,      // DependentAccess
                                        1,      // DependentSelect
                                        0,      // DependentProject
                                        0,      // DupRemove
                                        0,      // Grouping
                                        0,      // NestedLoopJoinStrategy
                                        0,      // MergeJoinStrategy
                                        0,      // Null
                                        0,      // PlanExecution
                                        1,      // Project
                                        0,      // Select
                                        0,      // Sort
                                        0       // UnionAll
                                    });  
       
        ProcessorPlan subplan = ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(((SelectNode)plan.getRootNode().getChildren()[0]).getCriteria()).get(0).getCommand().getProcessorPlan();
       
        // Collect atomic queries
        Set<String> actualQueries = getAtomicQueries(subplan);
       
        // Compare atomic queries
View Full Code Here

        Command command = TestProcessor.helpParse(sql);  
        ProcessorPlan plan = TestProcessor.helpGetPlan(command, fakeMetadata, capFinder);
       
        //Verify a dependent join (not merge join) was used
        assertTrue(plan instanceof RelationalPlan);
        RelationalPlan relationalPlan = (RelationalPlan)plan;
        RelationalNode project = relationalPlan.getRootNode();
        RelationalNode join = project.getChildren()[0];
        assertTrue("Expected instance of JoinNode (for dep join) but got " + join.getClass(), join instanceof JoinNode); //$NON-NLS-1$

        // Run query
        TestProcessor.helpProcess(plan, dataManager, expected);         
View Full Code Here

TOP

Related Classes of org.teiid.query.processor.relational.RelationalPlan

Copyright © 2018 www.massapicom. 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.