Search in sources :

Example 21 with CommandBuilder

use of org.teiid.cdk.CommandBuilder in project teiid by teiid.

the class TestSqlServerConversionVisitor method testWith.

@Test
public void testWith() throws Exception {
    // $NON-NLS-1$
    String input = "with x as /*+ no_inline */ (select intkey from bqt1.smalla) select intkey from x limit 100";
    // $NON-NLS-1$
    String output = "WITH x (IntKey) AS (SELECT g_0.IntKey FROM SmallA g_0) SELECT TOP 100 g_1.intkey AS c_0 FROM x g_1";
    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)

Example 22 with CommandBuilder

use of org.teiid.cdk.CommandBuilder in project teiid by teiid.

the class TestSqlServerConversionVisitor method testUnicodeLiteral.

@Test
public void testUnicodeLiteral() throws Exception {
    // $NON-NLS-1$
    String input = "select N'\u0FFF'";
    // $NON-NLS-1$
    String output = "SELECT N'\u0FFF'";
    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)

Example 23 with CommandBuilder

use of org.teiid.cdk.CommandBuilder in project teiid by teiid.

the class TestSqlServerConversionVisitor method testRowLimitWithInlineViewOrderBy.

@Test
public void testRowLimitWithInlineViewOrderBy() throws Exception {
    // $NON-NLS-1$
    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";
    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)

Example 24 with CommandBuilder

use of org.teiid.cdk.CommandBuilder in project teiid by teiid.

the class TestSqlServerConversionVisitor method testWithInsert.

@Test
public void testWithInsert() throws Exception {
    // $NON-NLS-1$
    String input = "insert into bqt1.smalla (intkey) with a (x) as /*+ no_inline */ (select intnum from bqt1.smallb) select x from a";
    // $NON-NLS-1$
    String output = "WITH a (x) AS (SELECT SmallB.IntNum FROM SmallB) INSERT INTO SmallA (IntKey) SELECT a.x FROM a";
    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)

Example 25 with CommandBuilder

use of org.teiid.cdk.CommandBuilder in project teiid by teiid.

the class TestSqlServerConversionVisitor method testLocate.

@Test
public void testLocate() throws Exception {
    // $NON-NLS-1$
    String input = "select locate('a', stringkey, 2) from bqt1.smalla";
    // $NON-NLS-1$
    String output = "SELECT CHARINDEX('a', g_0.StringKey, 2) 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

CommandBuilder (org.teiid.cdk.CommandBuilder)34 Test (org.junit.Test)31 Command (org.teiid.language.Command)25 SQLConversionVisitor (org.teiid.translator.jdbc.SQLConversionVisitor)9 TranslatedCommand (org.teiid.translator.jdbc.TranslatedCommand)9 ExecutionContext (org.teiid.translator.ExecutionContext)8 RuntimeMetadataImpl (org.teiid.dqp.internal.datamgr.RuntimeMetadataImpl)6 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)6 Properties (java.util.Properties)5 DataSource (javax.activation.DataSource)5 Call (org.teiid.language.Call)5 MetadataFactory (org.teiid.metadata.MetadataFactory)5 RealMetadataFactory (org.teiid.query.unittest.RealMetadataFactory)5 WSConnection (org.teiid.translator.WSConnection)5 Connection (java.sql.Connection)4 Select (org.teiid.language.Select)4 StAXSource (javax.xml.transform.stax.StAXSource)3 Procedure (org.teiid.metadata.Procedure)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 File (java.io.File)2