Search in sources :

Example 26 with SQLConversionVisitor

use of org.teiid.translator.jdbc.SQLConversionVisitor 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 27 with SQLConversionVisitor

use of org.teiid.translator.jdbc.SQLConversionVisitor 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 28 with SQLConversionVisitor

use of org.teiid.translator.jdbc.SQLConversionVisitor 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 29 with SQLConversionVisitor

use of org.teiid.translator.jdbc.SQLConversionVisitor in project teiid by teiid.

the class TestImpalaExecutionFactory method helpTest.

private void helpTest(Expression srcExpression, String tgtType, String expectedExpression) throws Exception {
    Function func = LANG_FACTORY.createFunction("convert", Arrays.asList(srcExpression, LANG_FACTORY.createLiteral(tgtType, String.class)), TypeFacility.getDataTypeClass(tgtType));
    SQLConversionVisitor sqlVisitor = impalaTranslator.getSQLConversionVisitor();
    sqlVisitor.append(func);
    assertEquals("Error converting from " + srcExpression.getType() + " to " + tgtType, expectedExpression, sqlVisitor.toString());
}
Also used : Function(org.teiid.language.Function) SQLConversionVisitor(org.teiid.translator.jdbc.SQLConversionVisitor)

Example 30 with SQLConversionVisitor

use of org.teiid.translator.jdbc.SQLConversionVisitor 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

SQLConversionVisitor (org.teiid.translator.jdbc.SQLConversionVisitor)31 Test (org.junit.Test)10 CommandBuilder (org.teiid.cdk.CommandBuilder)9 Command (org.teiid.language.Command)9 Function (org.teiid.language.Function)9 Select (org.teiid.language.Select)3 TranslatedCommand (org.teiid.translator.jdbc.TranslatedCommand)1 PhoenixExecutionFactory (org.teiid.translator.phoenix.PhoenixExecutionFactory)1