Package org.teiid.query.sql.symbol

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


            {        
                // Check that the PROJECT contains only functions that can be pushed                              
                List projectCols = (List) parentNode.getProperty(NodeConstants.Info.PROJECT_COLS);
               
                for (int i = 0; i < projectCols.size(); i++) {
                    SingleElementSymbol symbol = (SingleElementSymbol)projectCols.get(i);
                    if(! canPushSymbol(symbol, true, modelID, metadata, capFinder, record)) {
                        return null;
                    }
                }
               
View Full Code Here


              List<Object> keyCols = metadata.getElementIDsInKey(key);
              int[] reorder = new int[keyCols.size()];
              List<Integer> toCriteria = new ArrayList<Integer>(rightExpressions.size() - keyCols.size());
              List<SingleElementSymbol> keyExpressions = right?rightExpressions:leftExpressions;
            for (int j = 0; j < keyExpressions.size(); j++) {
          SingleElementSymbol ses = keyExpressions.get(j);
          if (!(ses instanceof ElementSymbol)) {
            continue;
          }
          ElementSymbol es = (ElementSymbol)ses;
          boolean found = false;
          for (int i = 0; !found && i < keyCols.size(); i++) {
            if (es.getMetadataID().equals(keyCols.get(i))) {
              reorder[i] = j;
              found = true;
            }
          }
          if (!found) {
            toCriteria.add(j);
          }
        }
            List<Criteria> joinCriteria = (List<Criteria>) joinNode.getProperty(Info.JOIN_CRITERIA);
            for (int index : toCriteria) {
          SingleElementSymbol lses = leftExpressions.get(index);
          SingleElementSymbol rses = rightExpressions.get(index);
          CompareCriteria cc = new CompareCriteria(lses, CompareCriteria.EQ, rses);
          if (joinCriteria == null || joinCriteria.isEmpty()) {
            joinCriteria = new ArrayList<Criteria>();
            joinCriteria.add(cc);
            joinNode.setProperty(Info.JOIN_TYPE, JoinType.JOIN_INNER);
View Full Code Here

    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);
    }
    SymbolMap newParentMap = SymbolMap.createSymbolMap(updatedVirturalElement, projectedViewSymbols);
    child.setProperty(NodeConstants.Info.SYMBOL_MAP, newParentMap);
    Map<AggregateSymbol, ElementSymbol> projectedMap = new HashMap<AggregateSymbol, ElementSymbol>();
View Full Code Here

      sortOrder = orderBy.getSortKeys();
    }
    List<SingleElementSymbol> projectCols = FrameUtil.findTopCols(unionSource);
    for (int i = 0; i < virtualElements.size(); i++) {
      ElementSymbol virtualElem = virtualElements.get(i);
      SingleElementSymbol projectedSymbol = projectCols.get(i);
      if (!projectedSymbol.getShortCanonicalName().equals(virtualElem.getShortCanonicalName())) {
        if (sortOrder != null) {
          int sortIndex = sortOrder.indexOf(projectedSymbol);
          if (sortIndex > -1) {
            updateSymbolName(sortOrder, sortIndex, virtualElem, sortOrder.get(sortIndex));
            orderBy.getOrderByItems().get(sortIndex).setSymbol(sortOrder.get(sortIndex));
View Full Code Here

            }
        }

        List<ElementSymbol> virtualElements = symbolMap.getKeys();
        for (int i = 0; i < selectSymbols.size(); i++) {
          SingleElementSymbol symbol = selectSymbols.get(i);
            Collection scalarSubqueries = ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(symbol);
            if (!scalarSubqueries.isEmpty()) {
                return false;
            }
            if (checkForNullDependent && JoinUtil.isNullDependent(metadata, groups, SymbolMap.getExpression(symbol))) {
View Full Code Here

        //further minimize the required symbols based upon underlying expression (accounts for aliasing)
        //TODO: this should depend upon whether the expressions are deterministic
        if (node.getType() == NodeConstants.Types.PROJECT) {
            Set<Expression> expressions = new HashSet<Expression>();
            for (Iterator<SingleElementSymbol> iterator = requiredSymbols.iterator(); iterator.hasNext();) {
                SingleElementSymbol ses = iterator.next();
                if (!expressions.add(SymbolMap.getExpression(ses))) {
                    iterator.remove();
                }
            }
        }
View Full Code Here

        Query query = (Query)helpParse(userSql);
       
        QueryResolver.resolveCommand(query, FakeMetadataFactory.exampleBQTCached());
       
        // Check type of resolved null constant
        SingleElementSymbol symbol = (SingleElementSymbol) query.getSelect().getSymbols().get(0);
        assertNotNull(symbol.getType());
        assertEquals(DataTypeManager.DefaultDataClasses.STRING, symbol.getType());
    }
View Full Code Here

   */               
  public static List<String> getOutputColumnProperties(List<SingleElementSymbol> projectedSymbols) {
      if(projectedSymbols != null) {
          List<String> outputCols = new ArrayList<String>(projectedSymbols.size());
          for(int i=0; i<projectedSymbols.size() ; i++) {
              SingleElementSymbol symbol = projectedSymbols.get(i);
              outputCols.add(symbol.getShortName() + " (" + DataTypeManager.getDataTypeName(symbol.getType()) + ")"); //$NON-NLS-1$ //$NON-NLS-2$
          }
          return outputCols;
      }
      return Collections.emptyList();
  }
View Full Code Here

                    List<SingleElementSymbol> newProjectSymbols = (List<SingleElementSymbol>)firstProject.getProperty(NodeConstants.Info.PROJECT_COLS);
                    List<SingleElementSymbol> oldProjectSymbols = (List<SingleElementSymbol>)nullNode.getProperty(NodeConstants.Info.PROJECT_COLS);
                   
                    for (int i = 0; i < newProjectSymbols.size(); i++) {
                        SingleElementSymbol newSes = newProjectSymbols.get(i);
                        SingleElementSymbol oldSes = oldProjectSymbols.get(i);
                        if (newSes instanceof ExpressionSymbol || !newSes.getShortCanonicalName().equals(oldSes.getShortCanonicalName())) {
                            if (newSes instanceof AliasSymbol) {
                                newSes = ((AliasSymbol)newSes).getSymbol();
                            }
                            newProjectSymbols.set(i, new AliasSymbol(oldSes.getShortName(), newSes));
                        }
                    }
                   
                    PlanNode sort = NodeEditor.findParent(firstProject, NodeConstants.Types.SORT, NodeConstants.Types.SOURCE);
                   
                    if (sort != null) { //correct the sort to the new columns as well
                        OrderBy sortOrder = (OrderBy)sort.getProperty(NodeConstants.Info.SORT_ORDER);
                        for (OrderByItem item : sortOrder.getOrderByItems()) {
                            SingleElementSymbol sortElement = item.getSymbol();
                            sortElement = newProjectSymbols.get(oldProjectSymbols.indexOf(sortElement));
                            item.setSymbol(sortElement);
                        }
                    }
                   
View Full Code Here

        for(int i=0; i<this.rows; i++) {       
            List row = new ArrayList();       
            Iterator iter = symbols.iterator();
            while(iter.hasNext()) {
                SingleElementSymbol symbol = (SingleElementSymbol) iter.next();
                Class type = symbol.getType();
                row.add( getValue(type) );
            }
            rows[i] = row;
        }  
       
View Full Code Here

TOP

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

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.