use of org.teiid.language.Command in project teiid by teiid.
the class TestTeradataTranslator method testPositionalOrderByUnion.
@Test
public void testPositionalOrderByUnion() throws Exception {
String input = "SELECT a as b, b as a from (SELECT intkey as a, stringkey as b from BQT1.smalla union SELECT intkey as a, stringkey as b from BQT1.smalla) as x order by a";
String output = "SELECT v_0.c_0, v_0.c_1 FROM (SELECT g_1.IntKey AS c_0, g_1.StringKey AS c_1 FROM SmallA AS g_1 UNION SELECT g_0.IntKey AS c_0, g_0.StringKey AS c_1 FROM SmallA AS g_0) AS v_0 ORDER BY 2";
TranslationUtility tu = TranslationHelper.getTranslationUtility(TranslationHelper.BQT_VDB, null);
Command command = tu.parseCommand(input, true, true);
TranslationHelper.helpTestVisitor(output, TRANSLATOR, command);
}
use of org.teiid.language.Command in project teiid by teiid.
the class TestTeradataTranslator method testPositionalOrderByUnion1.
@Test
public void testPositionalOrderByUnion1() throws Exception {
String input = "SELECT a as b from (SELECT intkey as a, stringkey as b from BQT1.smalla union SELECT intkey as a, stringkey as b from BQT1.smalla) as x order by x.b";
String output = "SELECT v_0.c_0 FROM (SELECT g_1.IntKey AS c_0, g_1.StringKey AS c_1 FROM SmallA AS g_1 UNION SELECT g_0.IntKey AS c_0, g_0.StringKey AS c_1 FROM SmallA AS g_0) AS v_0 ORDER BY v_0.c_1";
TranslationUtility tu = TranslationHelper.getTranslationUtility(TranslationHelper.BQT_VDB, null);
Command command = tu.parseCommand(input, true, true);
TranslationHelper.helpTestVisitor(output, TRANSLATOR, command);
}
use of org.teiid.language.Command in project teiid by teiid.
the class TestTeradataTranslator method testPositionalOrderBy.
@Test
public void testPositionalOrderBy() throws Exception {
String input = "SELECT INTKEY, BIGDECIMALVALUE FROM BQT1.SmallA ORDER BY intkey";
String output = "SELECT g_0.IntKey AS c_0, g_0.BigDecimalValue AS c_1 FROM SmallA AS g_0 ORDER BY 1";
TranslationUtility tu = TranslationHelper.getTranslationUtility(TranslationHelper.BQT_VDB, null);
Command command = tu.parseCommand(input, true, true);
TranslationHelper.helpTestVisitor(output, TRANSLATOR, command);
}
use of org.teiid.language.Command in project teiid by teiid.
the class TestJPADirectQueryExecution method testWithoutMarker.
@Test
public void testWithoutMarker() throws Exception {
String input = "exec native('jpa query')";
TranslationUtility util = FakeTranslationFactory.getInstance().getExampleTranslationUtility();
Command command = util.parseCommand(input);
ExecutionContext ec = Mockito.mock(ExecutionContext.class);
RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
EntityManager connection = Mockito.mock(EntityManager.class);
try {
JPQLDirectQueryExecution execution = (JPQLDirectQueryExecution) TRANSLATOR.createExecution(command, ec, rm, connection);
execution.execute();
fail("the above should have thrown exception");
} catch (TranslatorException e) {
}
}
use of org.teiid.language.Command in project teiid by teiid.
the class TestJPADirectQueryExecution method testCreate.
@Test
public void testCreate() throws Exception {
String input = "exec native('create;', 'one')";
TranslationUtility util = FakeTranslationFactory.getInstance().getExampleTranslationUtility();
Command command = util.parseCommand(input);
ExecutionContext ec = Mockito.mock(ExecutionContext.class);
RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
EntityManager connection = Mockito.mock(EntityManager.class);
ArgumentCaptor<String> argument = ArgumentCaptor.forClass(String.class);
Mockito.stub(connection.merge(argument.capture())).toReturn(new String("one"));
JPQLDirectQueryExecution execution = (JPQLDirectQueryExecution) TRANSLATOR.createExecution(command, ec, rm, connection);
execution.execute();
Mockito.verify(connection).merge(argument.capture());
assertEquals("one", argument.getValue());
}
Aggregations