Search in sources :

Example 61 with Command

use of org.teiid.language.Command in project teiid by teiid.

the class TestSybaseIQTranslator method helpTestVisitor.

public void helpTestVisitor(String vdb, String input, String expectedOutput) {
    // Convert from sql to objects
    Command obj = TranslationHelper.helpTranslate(vdb, input);
    TranslatedCommand tc = new TranslatedCommand(Mockito.mock(ExecutionContext.class), trans);
    try {
        tc.translateCommand(obj);
    } catch (TranslatorException e) {
        throw new RuntimeException(e);
    }
    // $NON-NLS-1$
    assertEquals("Did not get correct sql", expectedOutput, tc.getSql());
}
Also used : ExecutionContext(org.teiid.translator.ExecutionContext) Command(org.teiid.language.Command) TranslatedCommand(org.teiid.translator.jdbc.TranslatedCommand) TranslatedCommand(org.teiid.translator.jdbc.TranslatedCommand) TranslatorException(org.teiid.translator.TranslatorException)

Example 62 with Command

use of org.teiid.language.Command in project teiid by teiid.

the class TestSybaseSQLConversionVisitor method helpTestVisitor.

public void helpTestVisitor(String vdb, String input, String expectedOutput) {
    // Convert from sql to objects
    Command obj = TranslationHelper.helpTranslate(vdb, input);
    TranslatedCommand tc = new TranslatedCommand(Mockito.mock(ExecutionContext.class), trans);
    try {
        tc.translateCommand(obj);
    } catch (TranslatorException e) {
        throw new RuntimeException(e);
    }
    // $NON-NLS-1$
    assertEquals("Did not get correct sql", expectedOutput, tc.getSql());
}
Also used : ExecutionContext(org.teiid.translator.ExecutionContext) Command(org.teiid.language.Command) TranslatedCommand(org.teiid.translator.jdbc.TranslatedCommand) TranslatedCommand(org.teiid.translator.jdbc.TranslatedCommand) TranslatorException(org.teiid.translator.TranslatorException)

Example 63 with Command

use of org.teiid.language.Command in project teiid by teiid.

the class TestAccessSQLTranslator method helpTestVisitor.

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);
    // Check stuff
    // $NON-NLS-1$
    assertEquals("Did not get correct sql", expectedOutput, tc.getSql());
}
Also used : ExecutionContext(org.teiid.translator.ExecutionContext) Command(org.teiid.language.Command) TranslatedCommand(org.teiid.translator.jdbc.TranslatedCommand) TranslatedCommand(org.teiid.translator.jdbc.TranslatedCommand)

Example 64 with Command

use of org.teiid.language.Command in project teiid by teiid.

the class TestDB2SqlTranslator method helpTestVisitor.

public void helpTestVisitor(TranslationUtility util, String input, String expectedOutput) throws TranslatorException {
    // Convert from sql to objects
    Command obj = util.parseCommand(input);
    TranslatedCommand tc = new TranslatedCommand(Mockito.mock(ExecutionContext.class), TRANSLATOR);
    tc.translateCommand(obj);
    // $NON-NLS-1$
    assertEquals("Did not get correct sql", expectedOutput, tc.getSql());
}
Also used : ExecutionContext(org.teiid.translator.ExecutionContext) Command(org.teiid.language.Command) TranslatedCommand(org.teiid.translator.jdbc.TranslatedCommand) TranslatedCommand(org.teiid.translator.jdbc.TranslatedCommand)

Example 65 with Command

use of org.teiid.language.Command in project teiid by teiid.

the class TestSqlServerConversionVisitor method testBooleanExpression.

/**
 * the first column expression needs converted to a single clause case
 * the second column condition in the case should not be altered
 * the third column nested boolean expression needs converted accounting for 3 level logic
 */
@Test
public void testBooleanExpression() throws Exception {
    // $NON-NLS-1$
    String input = "select stringkey is null, case when stringkey = 'b' then 1 end, coalesce(intkey = 1, true) from bqt1.smalla";
    // $NON-NLS-1$
    String output = "SELECT CASE WHEN g_0.StringKey IS NULL THEN 1 ELSE 0 END, CASE WHEN g_0.StringKey = 'b' THEN 1 END, isnull(CASE WHEN g_0.IntKey = 1 THEN 1 WHEN NOT (g_0.IntKey = 1) THEN 0 END, 1) FROM SmallA g_0";
    CommandBuilder commandBuilder = new CommandBuilder(RealMetadataFactory.exampleBQTCached());
    Command obj = commandBuilder.getCommand(input, true, true);
    TranslationHelper.helpTestVisitor(output, trans, obj);
}
Also used : Command(org.teiid.language.Command) CommandBuilder(org.teiid.cdk.CommandBuilder) Test(org.junit.Test)

Aggregations

Command (org.teiid.language.Command)136 Test (org.junit.Test)99 ExecutionContext (org.teiid.translator.ExecutionContext)62 TranslationUtility (org.teiid.cdk.api.TranslationUtility)52 RuntimeMetadata (org.teiid.metadata.RuntimeMetadata)40 CommandBuilder (org.teiid.cdk.CommandBuilder)25 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)20 ResultSetExecution (org.teiid.translator.ResultSetExecution)18 TranslatedCommand (org.teiid.translator.jdbc.TranslatedCommand)17 UpdateExecution (org.teiid.translator.UpdateExecution)16 SimpleDBSQLVisitor (org.teiid.translator.simpledb.SimpleDBSQLVisitor)14 List (java.util.List)11 Connection (java.sql.Connection)10 LdapContext (javax.naming.ldap.LdapContext)9 Range (org.apache.accumulo.core.data.Range)9 SQLConversionVisitor (org.teiid.translator.jdbc.SQLConversionVisitor)9 MetadataFactory (org.teiid.metadata.MetadataFactory)8 ArrayList (java.util.ArrayList)7 FunctionTree (org.teiid.query.function.FunctionTree)7 UDFSource (org.teiid.query.function.UDFSource)7