Package org.teiid.query.sql.symbol

Examples of org.teiid.query.sql.symbol.GroupSymbol


                  return null;
                }
               
                //raise only if there is no intervening project into
                PlanNode parentProject = NodeEditor.findParent(parentNode, NodeConstants.Types.PROJECT);
                GroupSymbol intoGroup = (GroupSymbol)parentProject.getProperty(NodeConstants.Info.INTO_GROUP);
                if (intoGroup != null && parentProject.getParent() == null) {
                  if (CapabilitiesUtil.supports(Capability.INSERT_WITH_QUERYEXPRESSION, modelID, metadata, capFinder) && CapabilitiesUtil.isSameConnector(modelID, metadata.getModelID(intoGroup.getMetadataID()), metadata, capFinder)) {
                      rootNode = performRaise(rootNode, accessNode, parentNode);
                      return performRaise(rootNode, accessNode, parentProject);
                  }
                  return null;
                } else if (!CapabilitiesUtil.supportsInlineView(modelID, metadata, capFinder)) {
View Full Code Here


            for (Expression expr : leftExpressions) {
              if (expr instanceof ElementSymbol) {
                leftIds.add(((ElementSymbol) expr).getMetadataID());
              }
            }
            GroupSymbol rightGroup = null;
            for (Expression expr : rightExpressions) {
              if (expr instanceof ElementSymbol) {
                ElementSymbol es = (ElementSymbol) expr;
                if (rightGroup == null) {
                  rightGroup = es.getGroupSymbol();
                } else if (!rightGroup.equals(es.getGroupSymbol())) {
                  return null;
                }
                rightIds.add(es.getMetadataID());
              }
            }
View Full Code Here

    static Object getModelIDFromAccess(PlanNode accessNode, QueryMetadataInterface metadata)
    throws QueryMetadataException, TeiidComponentException {

        Object accessModelID = accessNode.getProperty(NodeConstants.Info.MODEL_ID);
        if(accessModelID == null && accessNode.getGroups().size() > 0) {
            GroupSymbol group = accessNode.getGroups().iterator().next();
            if(metadata.isVirtualGroup(group.getMetadataID())) {
                return null;
            }
            accessModelID = metadata.getModelID(group.getMetadataID());
   
            accessNode.setProperty(NodeConstants.Info.MODEL_ID, accessModelID);
        }
       
        return accessModelID;   
View Full Code Here

    //update the parent plan with the staged aggregates and the new projected symbols
    List<SingleElementSymbol> projectedViewSymbols = (List<SingleElementSymbol>)NodeEditor.findNodePreOrder(child, NodeConstants.Types.PROJECT).getProperty(NodeConstants.Info.PROJECT_COLS);
    List<ElementSymbol> updatedVirturalElement = new ArrayList<ElementSymbol>(virtualElements);
   
    //hack to introduce aggregate symbols to the parent view TODO: this should change the metadata properly.
    GroupSymbol virtualGroup = child.getGroups().iterator().next();
    for (int i = updatedVirturalElement.size(); i < projectedViewSymbols.size(); i++) {
      SingleElementSymbol symbol = projectedViewSymbols.get(i);
      String name = symbol.getShortName();
            String virtualElementName = virtualGroup.getCanonicalName() + ElementSymbol.SEPARATOR + name;
            ElementSymbol virtualElement = new ElementSymbol(virtualElementName);
            virtualElement.setGroupSymbol(virtualGroup);
            virtualElement.setType(symbol.getType());
            virtualElement.setMetadataID(new TempMetadataID(virtualElementName, symbol.getType()));
            updatedVirturalElement.add(virtualElement);
View Full Code Here

      List<SingleElementSymbol> groupingExpressions,
      LinkedHashSet<AggregateSymbol> aggregates,
      LinkedList<PlanNode> unionChildren, SymbolMap parentMap, CommandContext context, QueryMetadataInterface metadata, CapabilitiesFinder capFinder) throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
    // remove the group node
    groupNode.getParent().replaceChild(groupNode, groupNode.getFirstChild());
    GroupSymbol group = sourceNode.getGroups().iterator().next().clone();

    boolean first = true;
    List<SingleElementSymbol> symbols = null;
    for (PlanNode planNode : unionChildren) {
      PlanNode groupClone = NodeFactory.getNewNode(NodeConstants.Types.GROUP);
      groupClone.setProperty(Info.GROUP_COLS, LanguageObject.Util.deepClone(groupingExpressions, SingleElementSymbol.class));
      groupClone.addGroups(groupNode.getGroups());
     
      PlanNode view = RuleDecomposeJoin.createSource(group, planNode, parentMap);
     
      view.addAsParent(groupClone);
     
      PlanNode projectPlanNode = NodeFactory.getNewNode(NodeConstants.Types.PROJECT);
     
      Select allSymbols = new Select(groupingExpressions);
      allSymbols.addSymbols(aggregates);
      if (first) {
        first = false;
        QueryRewriter.makeSelectUnique(allSymbols, false);
        symbols = allSymbols.getSymbols();
      }
      projectPlanNode.setProperty(NodeConstants.Info.PROJECT_COLS, allSymbols.getSymbols());
        projectPlanNode.addGroups(view.getGroups());
       
        groupClone.addAsParent(projectPlanNode);
       
        if (planNode.getType() == NodeConstants.Types.ACCESS) {
          //TODO: temporarily remove the access node so that the inline view could be removed if possible
          while (RuleRaiseAccess.raiseAccessNode(planNode, planNode, metadata, capFinder, true, null) != null) {
              //continue to raise
            }
        }
    }
    GroupSymbol modifiedGroup = group.clone();
    SymbolMap symbolMap = createSymbolMap(modifiedGroup, symbols, sourceNode, metadata);
    sourceNode.setProperty(Info.SYMBOL_MAP, symbolMap);
   
    FrameUtil.convertFrame(sourceNode, group, Collections.singleton(modifiedGroup), symbolMap.inserseMapping(), metadata);
  }
View Full Code Here

          }
        }
        updateSymbolName(projectCols, i, virtualElem, projectedSymbol);
      }
    }
    GroupSymbol group = new GroupSymbol("X"); //$NON-NLS-1$
       
    PlanNode intermediateView = createView(group, virtualElements, unionSource, metadata);
      SymbolMap symbolMap = (SymbolMap)intermediateView.getProperty(Info.SYMBOL_MAP);
      unionSource = intermediateView;
     
View Full Code Here

  /**
   * Get deep clone of object
   * @return Deep copy of the object
   */
  public Object clone() {
      GroupSymbol copyGroup = null;
      if(this.group != null) {
          copyGroup = (GroupSymbol) this.group.clone();
      }
        UnaryFromClause clonedUnaryFromClause = new UnaryFromClause(copyGroup);
        clonedUnaryFromClause.setOptional(this.isOptional());
View Full Code Here

        Collection<GroupSymbol> subQueryGroups = GroupCollectorVisitor.getGroupsIgnoreInlineViews(queryCommand, false);
        if(subQueryGroups.size() == 0) {
            // No FROM?
            return null;
        }
        GroupSymbol subQueryGroup = subQueryGroups.iterator().next();

        Object modelID = subQueryGroup.getModelMetadataId();
        if (modelID == null) {
          modelID = metadata.getModelID(subQueryGroup.getMetadataID());
        }
        if (critNodeModelID == null) {
          critNodeModelID = modelID;
        } else if(!CapabilitiesUtil.isSameConnector(critNodeModelID, modelID, metadata, capFinder)) {
            return null;
View Full Code Here

 

  // ################################## TEST HELPERS ################################
 
  public void helpTestRecontextGroup(String oldGroupName, String oldGroupDefinition, String[] knownGroupNames, String expectedName) {
      GroupSymbol oldSymbol = null;     
      if(oldGroupDefinition == null) {
        oldSymbol = new GroupSymbol(oldGroupName);   
      } else {
          oldSymbol = new GroupSymbol(oldGroupName, oldGroupDefinition);
      }     
      oldSymbol.setMetadataID(oldSymbol.getName());    // Dummy metadata ID
                 
      Set<String> known = new HashSet<String>();
      for (int i = 0; i < knownGroupNames.length; i++) {
            known.add(knownGroupNames[i].toUpperCase());
        }
     
        GroupSymbol newSymbol = RulePlaceAccess.recontextSymbol(oldSymbol, known);
   
    assertEquals("New recontexted group name is not as expected: ", expectedName, newSymbol.getName());     //$NON-NLS-1$
  }
View Full Code Here

    void helpTest(String sql, String expected) throws Exception{
        FakeMetadataFacade metadata = TestXMLProcessor.exampleMetadataCached();
        Query query = (Query)TestXMLProcessor.helpGetCommand(sql, metadata);

        Collection groups = GroupCollectorVisitor.getGroups(query, true);
        GroupSymbol group = (GroupSymbol) groups.iterator().next();
       
        MappingDocument docOrig = (MappingDocument)metadata.getMappingNode(metadata.getGroupID(group.getName()));
        MappingDocument doc = (MappingDocument)docOrig.clone();
       
        doc = XMLPlanner.preMarkExcluded(query, doc);      
        XMLPlanner.removeExcluded(doc);
       
View Full Code Here

TOP

Related Classes of org.teiid.query.sql.symbol.GroupSymbol

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.