Search in sources :

Example 31 with CommandBuilder

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

the class TestHiveExecutionFactory method testStringLiteral.

@Test
public void testStringLiteral() {
    CommandBuilder commandBuilder = new CommandBuilder(RealMetadataFactory.example1Cached());
    Command obj = commandBuilder.getCommand("select pm1.g1.e2 from pm1.g1 where pm1.g1.e1 = 'a''b\\c'");
    SQLConversionVisitor sqlVisitor = hiveTranslator.getSQLConversionVisitor();
    sqlVisitor.append(obj);
    assertEquals("SELECT g1.e2 FROM g1 WHERE g1.e1 = 'a\\'b\\\\c'", sqlVisitor.toString());
}
Also used : SQLConversionVisitor(org.teiid.translator.jdbc.SQLConversionVisitor) Command(org.teiid.language.Command) TranslatedCommand(org.teiid.translator.jdbc.TranslatedCommand) CommandBuilder(org.teiid.cdk.CommandBuilder) Test(org.junit.Test)

Example 32 with CommandBuilder

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

the class TestImpalaExecutionFactory method testStringLiteral.

@Test
public void testStringLiteral() {
    CommandBuilder commandBuilder = new CommandBuilder(RealMetadataFactory.example1Cached());
    Command obj = commandBuilder.getCommand("select pm1.g1.e2 from pm1.g1 where pm1.g1.e1 = 'a''b\\c'");
    SQLConversionVisitor sqlVisitor = impalaTranslator.getSQLConversionVisitor();
    sqlVisitor.append(obj);
    assertEquals("SELECT g1.e2 FROM g1 WHERE g1.e1 = 'a\\'b\\\\c'", sqlVisitor.toString());
}
Also used : SQLConversionVisitor(org.teiid.translator.jdbc.SQLConversionVisitor) Command(org.teiid.language.Command) CommandBuilder(org.teiid.cdk.CommandBuilder) Test(org.junit.Test)

Example 33 with CommandBuilder

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

the class TestImpalaExecutionFactory method testJoin.

@Test
public void testJoin() {
    CommandBuilder commandBuilder = new CommandBuilder(RealMetadataFactory.example1Cached());
    Command obj = commandBuilder.getCommand("select pm1.g1.e1 from pm1.g1 inner join pm1.g2 inner join pm1.g3 on pm1.g2.e2 = pm1.g3.e2 on pm1.g1.e1 = pm1.g2.e1");
    SQLConversionVisitor sqlVisitor = impalaTranslator.getSQLConversionVisitor();
    sqlVisitor.append(obj);
    assertEquals("SELECT g1.e1 FROM g2  JOIN g3 ON g2.e2 = g3.e2  JOIN g1 ON g1.e1 = g2.e1", sqlVisitor.toString());
}
Also used : SQLConversionVisitor(org.teiid.translator.jdbc.SQLConversionVisitor) Command(org.teiid.language.Command) CommandBuilder(org.teiid.cdk.CommandBuilder) Test(org.junit.Test)

Example 34 with CommandBuilder

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

the class TestImpalaExecutionFactory method testLikeRegex.

@Test
public void testLikeRegex() {
    CommandBuilder commandBuilder = new CommandBuilder(RealMetadataFactory.exampleBQTCached());
    Select obj = (Select) commandBuilder.getCommand("SELECT max(StringNum) as a FROM bqt1.SmallA where stringkey like_regex '^[1-9]$'");
    SQLConversionVisitor sqlVisitor = impalaTranslator.getSQLConversionVisitor();
    sqlVisitor.append(obj);
    assertEquals("SELECT MAX(SmallA.StringNum) AS a FROM SmallA WHERE SmallA.StringKey REGEXP '^[1-9]$'", sqlVisitor.toString());
}
Also used : SQLConversionVisitor(org.teiid.translator.jdbc.SQLConversionVisitor) Select(org.teiid.language.Select) 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