Package org.teiid.query.sql.lang

Examples of org.teiid.query.sql.lang.Query


     * @param command
     * @return
     */
    static boolean hasNoCriteria(Command command) {
      if(command instanceof Query) {
            Query query = (Query) command;
            return query.getCriteria() == null;
        }
        if (command instanceof Delete) {
          Delete query = (Delete) command;
            return query.getCriteria() == null;
        }
        if (command instanceof Update) {
          Update query = (Update) command;
            return query.getCriteria() == null;
        }
        if (command instanceof SetQuery) {
          SetQuery query = (SetQuery)command;
          return hasNoCriteria(query.getLeftQuery()) || hasNoCriteria(query.getRightQuery());
        }
        return false;
    }
View Full Code Here


        ElementSymbol e1 = new ElementSymbol("e1"); //$NON-NLS-1$
        ElementSymbol x1 = new ElementSymbol("x1"); //$NON-NLS-1$
        Map<ElementSymbol, ElementSymbol> symbolMap = new HashMap<ElementSymbol, ElementSymbol>();
        symbolMap.put(e1, x1);
       
        Query query = new Query();
        SubqueryCompareCriteria crit = new SubqueryCompareCriteria(e1, query, SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.ALL);
        SubqueryCompareCriteria expected = new SubqueryCompareCriteria(x1, query, SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.ALL);

        FrameUtil.convertCriteria(crit, symbolMap, null, true)
       
View Full Code Here

*/
public class TestMarkExcludeVisitor extends TestCase {
   
    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()));
View Full Code Here

    public void testHasNoCriteria1() {
        assertEquals("Got incorrect answer checking for no criteria", false, RuleValidateWhereAll.hasNoCriteria(new Insert())); //$NON-NLS-1$
    }

    public void testHasNoCriteria2() {
        Query query = new Query();
        CompareCriteria crit = new CompareCriteria(new Constant("a"), CompareCriteria.EQ, new Constant("b")); //$NON-NLS-1$ //$NON-NLS-2$
        query.setCriteria(crit);       
        assertEquals("Got incorrect answer checking for no criteria", false, RuleValidateWhereAll.hasNoCriteria(query)); //$NON-NLS-1$
    }
View Full Code Here

        query.setCriteria(crit);       
        assertEquals("Got incorrect answer checking for no criteria", false, RuleValidateWhereAll.hasNoCriteria(query)); //$NON-NLS-1$
    }

    public void testHasNoCriteria3() {
        assertEquals("Got incorrect answer checking for no criteria", true, RuleValidateWhereAll.hasNoCriteria(new Query())); //$NON-NLS-1$
    }
View Full Code Here

     * Tests that any access patterns (a Collection of Collections of
     * Object element ids) for a physical group will be found and added
     * as a property of an ACCESS node.
     */
    public void testAddAccessPatterns2() throws Exception {
        Query query = new Query();
       
        From from = new From();
        GroupSymbol group = new GroupSymbol("pm4.g2"); //$NON-NLS-1$
        from.addGroup(group);
        query.setFrom(from);
       
        Select select = new Select();
        select.addSymbol(new AllSymbol());
        query.setSelect(select);

        group.setMetadataID(METADATA.getGroupID("pm4.g2")); //$NON-NLS-1$
               
        PlanNode n1 = NodeFactory.getNewNode(NodeConstants.Types.ACCESS);
        n1.setProperty(NodeConstants.Info.ATOMIC_REQUEST, query);
View Full Code Here

public class TestNameInSourceResolverVisitor extends TestCase {
    static HashMap infos = new HashMap();
   
    XMLPlannerEnvironment getEnv(String sql) 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()));
View Full Code Here

     * and update the processing logic (this requires that we can guarantee null ordering) to assume sorted
     */
    if (queryCommand instanceof SetQuery) {
      ((SetQuery)queryCommand).setAll(false);
    } else if (!NewCalculateCostUtil.usesKey(accessNode, queryCommand.getProjectedSymbols(), metadata) && CapabilitiesUtil.supports(Capability.QUERY_SELECT_DISTINCT, RuleRaiseAccess.getModelIDFromAccess(accessNode, metadata), metadata, capFinder)) {
      Query query = (Query)queryCommand;
      if (!QueryRewriter.isDistinctWithGroupBy(query)) {
        ((Query)queryCommand).getSelect().setDistinct(true);
      }
    }
  }
View Full Code Here

                }
                count++;
            }
            return unionCommand;
        }
    Query query = new Query();
        Select select = new Select();
        List<SingleElementSymbol> columns = (List<SingleElementSymbol>)node.getProperty(NodeConstants.Info.OUTPUT_COLS);
        prepareSubqueries(ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(columns));
        select.addSymbols(columns);
        query.setSelect(select);
    query.setFrom(new From());
    buildQuery(accessRoot, node, query, metadata, capFinder);
    if (query.getCriteria() instanceof CompoundCriteria) {
            query.setCriteria(QueryRewriter.optimizeCriteria((CompoundCriteria)query.getCriteria(), metadata));
        }
    if (!CapabilitiesUtil.useAnsiJoin(RuleRaiseAccess.getModelIDFromAccess(accessRoot, metadata), metadata, capFinder)) {
      simplifyFromClause(query);
        }
    if (columns.isEmpty()) {
          if (CapabilitiesUtil.supports(Capability.QUERY_SELECT_EXPRESSION, RuleRaiseAccess.getModelIDFromAccess(accessRoot, metadata), metadata, capFinder)) {
            select.addSymbol(new ExpressionSymbol("dummy", new Constant(1))); //$NON-NLS-1$
          } else {
            //TODO: need to ensure the type is consistent 
            //- should be rare as the source would typically support select expression if it supports union
            select.addSymbol(selectOutputElement(query.getFrom().getGroups(), metadata));
          }
        }
    return query;
  }   
View Full Code Here

        from.addClause(clause1);

        Select select = new Select();
        select.addSymbol(a);               

        Query query = new Query();
        query.setSelect(select);
        query.setFrom(from);
        query.setCriteria(crit);
        TestParser.helpTest("Select a From db.g1 MAKENOTDEP, db.g2 AS c MAKENOTDEP WHERE a = b"//$NON-NLS-1$
                 "SELECT a FROM db.g1 MAKENOTDEP, db.g2 AS c MAKENOTDEP WHERE a = b"//$NON-NLS-1$
                 query);
    }
View Full Code Here

TOP

Related Classes of org.teiid.query.sql.lang.Query

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.