Package org.teiid.language

Examples of org.teiid.language.Command


    }
   
    @Test public void testOrderByAlias() throws Exception {
      String sql = "select intkey as x from bqt1.smalla order by x"; //$NON-NLS-1$
     
      Command command = FakeTranslationFactory.getInstance().getBQTTranslationUtility().parseCommand(sql, true, true);
      assertEquals("SELECT g_0.IntKey AS c_0 FROM SmallA AS g_0 ORDER BY c_0", command.toString()); //$NON-NLS-1$
    }
View Full Code Here


    }
   
    @Test public void testOrderByNullOrdering() throws Exception {
      String sql = "select intkey as x from bqt1.smalla order by x nulls first"; //$NON-NLS-1$
     
      Command command = FakeTranslationFactory.getInstance().getBQTTranslationUtility().parseCommand(sql, true, true);
      assertEquals("SELECT g_0.IntKey AS c_0 FROM SmallA AS g_0 ORDER BY c_0 NULLS FIRST", command.toString()); //$NON-NLS-1$
    }
View Full Code Here

        }
    }
   
    public void helpTestVisitor(String input, String expectedOutput) throws TranslatorException {
        // Convert from sql to objects
        Command obj = FakeTranslationFactory.getInstance().getBQTTranslationUtility().parseCommand(input);
       
        TranslatedCommand tc = new TranslatedCommand(Mockito.mock(ExecutionContext.class), TRANSLATOR);
        tc.translateCommand(obj);
       
       
View Full Code Here

        return UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb"; //$NON-NLS-1$
    }
   
    public void helpTestTranslate(String sql, String expectedOutput) {
        TranslationUtility util = new TranslationUtility(getTestVDB());
        Command query = util.parseCommand(sql);        
        assertEquals(expectedOutput, query.toString());       
    }
View Full Code Here

       
        CompositeMetadataStore store = new CompositeMetadataStore(metadataStore);
        QueryMetadataInterface metadata = new TransformationMetadata(null, store, null, FakeMetadataFactory.SFM.getSystemFunctions(), null);
       
        TranslationUtility tu = new TranslationUtility(metadata);
        Command command = tu.parseCommand("select max(x) from bar"); //$NON-NLS-1$
        TranslationHelper.helpTestVisitor("SELECT MAX(cast(bar.x as char(36))) FROM bar", trans, command); //$NON-NLS-1$
       
        command = tu.parseCommand("select * from (select max(x) as max from bar) x"); //$NON-NLS-1$
        TranslationHelper.helpTestVisitor("SELECT x.max FROM (SELECT MAX(cast(bar.x as char(36))) AS max FROM bar) x", trans, command); //$NON-NLS-1$
    }
View Full Code Here

    @Test public void testRowLimitWithInlineViewOrderBy() throws Exception {
        String input = "select intkey from (select intkey from bqt1.smalla) as x order by intkey limit 100"; //$NON-NLS-1$
        String output = "SELECT TOP 100 v_0.c_0 FROM (SELECT g_0.IntKey AS c_0 FROM SmallA g_0) v_0 ORDER BY v_0.c_0"; //$NON-NLS-1$
              
    CommandBuilder commandBuilder = new CommandBuilder(FakeMetadataFactory.exampleBQTCached());
        Command obj = commandBuilder.getCommand(input, true, true);
        TranslationHelper.helpTestVisitor(output, trans, obj);
    }
View Full Code Here

import org.teiid.translator.ExecutionContext;

public class TestJDBCProcedureExecution {
 
  @Test public void testProcedureExecution() throws Exception {
    Command command = TranslationHelper.helpTranslate(TranslationHelper.BQT_VDB, "exec pm2.spTest8a()"); //$NON-NLS-1$
    Connection connection = Mockito.mock(Connection.class);
    CallableStatement cs = Mockito.mock(CallableStatement.class);
    Mockito.stub(cs.getUpdateCount()).toReturn(-1);
    Mockito.stub(cs.getInt(1)).toReturn(5);
    Mockito.stub(connection.prepareCall("{  call spTest8a(?)}")).toReturn(cs); //$NON-NLS-1$
View Full Code Here

    procedureExecution.execute();
    assertEquals(Arrays.asList(5), procedureExecution.getOutputParameterValues());
    Mockito.verify(cs, Mockito.times(1)).registerOutParameter(1, Types.INTEGER);
  }
  @Test public void testProcedureExecution1() throws Exception {
    Command command = TranslationHelper.helpTranslate(TranslationHelper.BQT_VDB, "exec pm2.spTest8(1)"); //$NON-NLS-1$
    Connection connection = Mockito.mock(Connection.class);
    CallableStatement cs = Mockito.mock(CallableStatement.class);
    Mockito.stub(cs.getUpdateCount()).toReturn(-1);
    Mockito.stub(cs.getInt(2)).toReturn(5);
    Mockito.stub(connection.prepareCall("{  call spTest8(?,?)}")).toReturn(cs); //$NON-NLS-1$
View Full Code Here

import org.teiid.translator.ExecutionContext;

public class TestJDBCUpdateExecution {

  @Test public void testBulkUpdate() throws Exception {
    Command command = TranslationHelper.helpTranslate(TranslationHelper.BQT_VDB, "insert into BQT1.SmallA (IntKey, IntNum) values (1, 2)"); //$NON-NLS-1$
    Literal value = ((Literal)((ExpressionValueSource)((Insert)command).getValueSource()).getValues().get(0));
    Literal value1 = ((Literal)((ExpressionValueSource)((Insert)command).getValueSource()).getValues().get(1));
    value.setMultiValued(true);
    value.setBindValue(true);
    value.setValue(Arrays.asList(1, 2));
View Full Code Here

    public void setExecutionContext(ExecutionContext context) {
      this.executionContext = context;
    }
   
    public List executeCommand(String query) throws TranslatorException {
        Command command = getCommand(query);
        RuntimeMetadata runtimeMetadata = getRuntimeMetadata();

        return executeCommand(command, runtimeMetadata, true);
    }
View Full Code Here

TOP

Related Classes of org.teiid.language.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.