Package org.teiid.language

Examples of org.teiid.language.Select


    visitor.visit(command);
    assertEquals("SELECT Contact.ContactName FROM Contact WHERE ContactName IN('x','y')", visitor.getQuery().toString().trim()); //$NON-NLS-1$
  }
 
  @Test public void testIDCriteria() throws Exception {
    Select command = (Select)translationUtility.parseCommand("select id, name from Account where id = 'bar'"); //$NON-NLS-1$
    SalesforceConnection sfc = Mockito.mock(SalesforceConnection.class);
    QueryExecutionImpl qei = new QueryExecutionImpl(command, sfc, translationUtility.createRuntimeMetadata(), Mockito.mock(ExecutionContext.class));
    qei.execute();
    Mockito.verify(sfc).retrieve("Account.id, Account.AccountName", "Account", Arrays.asList("bar"));
  }
View Full Code Here


  }
 
  @Test public void testDateTimeFormating() throws Exception {
    TimeZone.setDefault(TimeZone.getTimeZone("GMT-06:00"));
    try {
      Select command = (Select)translationUtility.parseCommand("select name from contacts where initialcontact = {ts'2003-03-11 11:42:10.5'}"); //$NON-NLS-1$
      SelectVisitor visitor = new SelectVisitor(translationUtility.createRuntimeMetadata());
      visitor.visit(command);
      assertEquals("SELECT Contact.ContactName FROM Contact WHERE Contact.InitialContact = 2003-03-11T11:42:10.500-06:00", visitor.getQuery().toString().trim()); //$NON-NLS-1$
    } finally {
      TimeZone.setDefault(null);
View Full Code Here

        symbols.add(new ColumnReference(g, "e1", null, String.class)); //$NON-NLS-1$
        Function function = new Function("length", Arrays.asList(new ColumnReference(g, "e2", null, String.class)), Integer.class); //$NON-NLS-1$ //$NON-NLS-2$
        symbols.add(function);
        List groups = new ArrayList();
        groups.add(g);
        Select q = new Select(symbols, false, groups, null, null, null, null);
            
        return q;  
    }
View Full Code Here

    @Test public void testInsertWithQuery() throws Exception {
      String sql = "insert into pm1.g1 values (null, null, null, null)"; //$NON-NLS-1$

      Insert insert = (Insert)FakeTranslationFactory.getInstance().getExampleTranslationUtility().parseCommand(sql);
     
      Select command = (Select)FakeTranslationFactory.getInstance().getExampleTranslationUtility().parseCommand("select * from pm1.g2"); //$NON-NLS-1$
      insert.setValueSource(command);
      assertEquals("INSERT INTO g1 (e1, e2, e3, e4) SELECT g2.e1, g2.e2, g2.e3, g2.e4 FROM g2", insert.toString()); //$NON-NLS-1$
    }
View Full Code Here

public class TestQueryExecutionImpl {
 
  private static TranslationUtility translationUtility = new TranslationUtility(TestVisitors.exampleSalesforce());

  @Test public void testBatching() throws Exception {
    Select command = (Select)translationUtility.parseCommand("select Name from Account"); //$NON-NLS-1$
    SalesforceConnection sfc = Mockito.mock(SalesforceConnection.class);
    QueryResult qr = new QueryResult();
    SObject so = new SObject();
    so.setType("Account");
    Element elem = Mockito.mock(Element.class);
View Full Code Here

    public void testGetRMD() throws Exception {
        TranslationUtility util = new TranslationUtility(getTestVDB());
       
        // Translate command to get some ids
        Select query = (Select) util.parseCommand("select * from partssupplier.parts"); //$NON-NLS-1$
        NamedTable group = (NamedTable) query.getFrom().get(0);
        AbstractMetadataRecord mid = group.getMetadataObject();
        assertEquals("PartsSupplier.PARTSSUPPLIER.PARTS", mid.getFullName()); //$NON-NLS-1$
       
        // Use RMD to get stuff
        assertEquals("PARTS", mid.getNameInSource()); //$NON-NLS-1$
View Full Code Here

    public void testGetQuery() throws Exception {
        assertNotNull(example().getSubquery());    }
   
    public void testGetType() throws Exception {
        Select query = TstLanguageBridgeFactory.factory.translate(TestQueryImpl.helpExample(true));
        Class<?> firstSymbolType = query.getDerivedColumns().get(0).getExpression().getType();
        assertEquals("Got incorrect type", firstSymbolType, example().getType()); //$NON-NLS-1$
    }
View Full Code Here

        List<DerivedColumn> symbols = new ArrayList<DerivedColumn>();
        symbols.add(new DerivedColumn("c1", new Literal("3", DataTypeManager.DefaultDataClasses.STRING)))//$NON-NLS-1$//$NON-NLS-2$
        expectedResults[0] = DataTypeManager.DefaultDataClasses.STRING;
        symbols.add(new DerivedColumn("c2", new Literal(new Integer(5), DataTypeManager.DefaultDataClasses.INTEGER)))//$NON-NLS-1$
        expectedResults[1] = DataTypeManager.DefaultDataClasses.INTEGER;
        Select query = new Select(symbols, false, null, null, null, null, null);
        Class<?>[] results = query.getColumnTypes()
        assertEquals( results[0], expectedResults[0]);
        assertEquals( results[1], expectedResults[1]);    
    }
View Full Code Here

        symbols2.add(symbol2);
       
        List items2 = new ArrayList();
        items2.add(group2);
       
        Select secondQuery = new Select(symbols2, false, items2, null, null, null, null);
       
        Select query = new Select(symbols, false, items, null, null, null, null);
       
        SetQuery setQuery = new SetQuery();
        setQuery.setOperation(SetQuery.Operation.UNION);
        setQuery.setAll(true);
        setQuery.setLeftQuery(query);
View Full Code Here

     
      LDAPExecutionFactory config = mock(LDAPExecutionFactory.class);
     
      IQueryToLdapSearchParser searchParser = new IQueryToLdapSearchParser(config);
     
        Select query = (Select)getCommand(queryString, metadata);

        LDAPSearchDetails searchDetails = searchParser.translateSQLQueryToLDAPSearch(query);
    return searchDetails;
  }
View Full Code Here

TOP

Related Classes of org.teiid.language.Select

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.