Package org.teiid.query.sql.lang

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


  private static final QueryMetadataInterface EXAMPLE_BQT = FakeMetadataFactory.exampleBQTCached();

  private static Command helpGetCommand(String sql,
      QueryMetadataInterface metadata) throws Exception {
    Command command = QueryParser.getQueryParser().parseCommand(sql);
    QueryResolver.resolveCommand(command, metadata);
    return command;
  }
View Full Code Here


    assertEquals(Integer.valueOf(1), results.getResults()[0].get(0));
  }

  private AtomicResultsMessage helpExecuteUpdate() throws Exception,
      Throwable {
    Command command = helpGetCommand("update bqt1.smalla set stringkey = 1 where stringkey = 2", EXAMPLE_BQT); //$NON-NLS-1$
    AtomicRequestMessage arm = createNewAtomicRequestMessage(1, 1);
    arm.setCommand(command);
    ConnectorWorkItem synchConnectorWorkItem = new ConnectorWorkItem(arm, TestConnectorManager.getConnectorManager());
    return synchConnectorWorkItem.execute();
  }
View Full Code Here

    ConnectorManager cm = TestConnectorManager.getConnectorManager();
    ((FakeConnector)cm.getExecutionFactory()).setImmutable(true);
   

    // command must not be a SELECT
    Command command = helpGetCommand("update bqt1.smalla set stringkey = 1 where stringkey = 2", EXAMPLE_BQT); //$NON-NLS-1$
    AtomicRequestMessage requestMsg = createNewAtomicRequestMessage(1, 1);
    requestMsg.setCommand(command);
   
    // To make the AtomicRequestMessage transactional, construct your own
    requestMsg.setTransactionContext( new TransactionContext(){
View Full Code Here

    ConnectorManager cm = TestConnectorManager.getConnectorManager();
    ((FakeConnector)cm.getExecutionFactory()).setImmutable(false);
   
       
    // command must not be a SELECT
    Command command = helpGetCommand("update bqt1.smalla set stringkey = 1 where stringkey = 2", EXAMPLE_BQT); //$NON-NLS-1$
    AtomicRequestMessage requestMsg = createNewAtomicRequestMessage(1, 1);
    requestMsg.setCommand(command);
   
    // To make the AtomicRequestMessage transactional, construct your own
    requestMsg.setTransactionContext( new TransactionContext(){
View Full Code Here

@SuppressWarnings({"nls", "unchecked"})
public class TestMetaDataProcessor {

  public Map[] helpGetMetadata(String sql, QueryMetadataInterface metadata, VDBMetaData vdb) throws Exception {
        // Prepare sql
        Command command = QueryParser.getQueryParser().parseCommand(sql);
        QueryResolver.resolveCommand(command, metadata);
       
        // Create components
        SessionAwareCache<PreparedPlan> prepPlanCache = new SessionAwareCache<PreparedPlan>();
        DQPCore requestMgr = new DQPCore();
View Full Code Here

    static void helpTest(String sql, String expectedString, Command expectedCommand) {
        helpTest(sql, expectedString, expectedCommand, new ParseInfo());
    }
  static void helpTest(String sql, String expectedString, Command expectedCommand, ParseInfo info) {
    Command actualCommand = null;
    String actualString = null;
    try {
      actualCommand = QueryParser.getQueryParser().parseCommand(sql, info);
      actualString = actualCommand.toString();
    } catch(Throwable e) {
        throw new RuntimeException(e);
    }

    assertEquals("Parse string does not match: ", expectedString, actualString); //$NON-NLS-1$
    assertEquals("Command objects do not match: ", expectedCommand, actualCommand);         //$NON-NLS-1$
    assertEquals("Cloned command objects do not match: ", expectedCommand, actualCommand.clone());         //$NON-NLS-1$
  }
View Full Code Here

    }
      
    @Test public void testCommandStatement() throws Exception {
        Query query = sampleQuery();
       
        Command sqlCmd = query;
        CommandStatement cmdStmt = new CommandStatement(sqlCmd);
  
        helpStmtTest("SELECT a1 FROM g WHERE a2 = 5;", "SELECT a1 FROM g WHERE a2 = 5;", //$NON-NLS-1$ //$NON-NLS-2$
        cmdStmt);      
    }
View Full Code Here

        Query elseQuery = new Query();
        elseQuery.setSelect(elseSelect);
        elseQuery.setFrom(from);
        elseQuery.setCriteria(criteria);
       
        Command elseQueryCmd = elseQuery;
        AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQuery);
       
        Block elseBlock = new Block();
        List elseStmts = new ArrayList();
        elseStmts.add(elseDeclStmt);
View Full Code Here

        }
       
        MultiSourceMetadataWrapper wrapper = new MultiSourceMetadataWrapper(metadata, multiSourceModels);
        AnalysisRecord analysis = new AnalysisRecord(false, DEBUG);
       
        Command command = TestResolver.helpResolve(userSql, wrapper);              
               
        // Plan
        command = QueryRewriter.rewrite(command, wrapper, null);
        FakeCapabilitiesFinder fakeFinder = new FakeCapabilitiesFinder();
        fakeFinder.addCapabilities(multiModel, TestOptimizer.getTypicalCapabilities());
View Full Code Here

        return wrapper;
    }
   
    public void helpTest(String sql, QueryMetadataInterface metadata, String expected) throws Exception {
        QueryParser parser = new QueryParser();
        Command command = parser.parseCommand(sql);
        QueryResolver.resolveCommand(command, metadata);       
       
        MultiSourceElementReplacementVisitor visitor = new MultiSourceElementReplacementVisitor("x"); //$NON-NLS-1$
        DeepPostOrderNavigator.doVisit(command, visitor);
       
        assertEquals(expected, command.toString());
    }
View Full Code Here

TOP

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

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.