use of org.teiid.translator.jdbc.SQLConversionVisitor in project teiid by teiid.
the class TestImpalaExecutionFactory method testWith.
@Test
public void testWith() {
CommandBuilder commandBuilder = new CommandBuilder(RealMetadataFactory.exampleBQTCached());
Select obj = (Select) commandBuilder.getCommand("with x as /*+ no_inline */ (SELECT max(StringNum) as a FROM bqt1.SmallA group by stringkey) select * from x");
SQLConversionVisitor sqlVisitor = impalaTranslator.getSQLConversionVisitor();
sqlVisitor.append(obj);
assertEquals("WITH x AS (SELECT MAX(SmallA.StringNum) AS a FROM SmallA GROUP BY SmallA.StringKey) SELECT x.a FROM x", sqlVisitor.toString());
}
use of org.teiid.translator.jdbc.SQLConversionVisitor in project teiid by teiid.
the class TestImpalaExecutionFactory method testOffset.
@Test
public void testOffset() {
CommandBuilder commandBuilder = new CommandBuilder(RealMetadataFactory.example1Cached());
Command obj = commandBuilder.getCommand("select pm1.g1.e2 from pm1.g1 limit 1, 2");
SQLConversionVisitor sqlVisitor = impalaTranslator.getSQLConversionVisitor();
sqlVisitor.append(obj);
assertEquals("SELECT g1.e2 FROM g1 ORDER BY 1 LIMIT 2 OFFSET 1", sqlVisitor.toString());
obj = commandBuilder.getCommand("select pm1.g1.e2, pm1.g1.e1 from pm1.g1 order by e1 limit 1, 100");
sqlVisitor = impalaTranslator.getSQLConversionVisitor();
sqlVisitor.append(obj);
assertEquals("SELECT g1.e2, g1.e1 FROM g1 ORDER BY e1 LIMIT 100 OFFSET 1", sqlVisitor.toString());
}
use of org.teiid.translator.jdbc.SQLConversionVisitor in project teiid by teiid.
the class TestImpalaExecutionFactory method testDistinctAggregate.
@Test
public void testDistinctAggregate() {
CommandBuilder commandBuilder = new CommandBuilder(RealMetadataFactory.exampleBQTCached());
Command obj = commandBuilder.getCommand("SELECT distinct max(StringNum) FROM bqt1.SmallA group by stringkey");
SQLConversionVisitor sqlVisitor = impalaTranslator.getSQLConversionVisitor();
sqlVisitor.append(obj);
assertEquals("SELECT DISTINCT c_0 FROM (SELECT MAX(SmallA.StringNum) AS c_0 FROM SmallA GROUP BY SmallA.StringKey) X__", sqlVisitor.toString());
}
use of org.teiid.translator.jdbc.SQLConversionVisitor in project teiid by teiid.
the class TestImpalaExecutionFactory method testOrderedUnion.
@Test
public void testOrderedUnion() {
CommandBuilder commandBuilder = new CommandBuilder(RealMetadataFactory.exampleBQTCached());
Command obj = commandBuilder.getCommand("SELECT g_1.StringNum AS c_0 FROM bqt1.SmallA AS g_1 WHERE g_1.IntKey <= 50 UNION ALL SELECT g_0.StringNum AS c_0 FROM bqt1.SmallB AS g_0 WHERE g_0.IntKey > 50 ORDER BY c_0 limit 10");
SQLConversionVisitor sqlVisitor = impalaTranslator.getSQLConversionVisitor();
sqlVisitor.append(obj);
assertEquals("SELECT c_0 FROM (SELECT g_1.StringNum AS c_0 FROM SmallA g_1 WHERE g_1.IntKey <= 50 UNION ALL SELECT g_0.StringNum AS c_0 FROM SmallB g_0 WHERE g_0.IntKey > 50) X__ ORDER BY c_0 LIMIT 10", sqlVisitor.toString());
}
use of org.teiid.translator.jdbc.SQLConversionVisitor in project teiid by teiid.
the class TestImpalaExecutionFactory method testMultipleDistinctAggregates.
@Test
public void testMultipleDistinctAggregates() {
CommandBuilder commandBuilder = new CommandBuilder(RealMetadataFactory.example1Cached());
Command obj = commandBuilder.getCommand("select count(distinct pm1.g1.e1), 1, count(distinct pm1.g1.e2), avg(distinct pm1.g1.e4) from pm1.g1");
SQLConversionVisitor sqlVisitor = impalaTranslator.getSQLConversionVisitor();
sqlVisitor.append(obj);
assertEquals("SELECT v0.c0, v0.c1, v1.c2, v2.c3 FROM (SELECT COUNT(DISTINCT g1.e1) AS c0, 1 AS c1 FROM g1) v0 CROSS JOIN (SELECT COUNT(DISTINCT g1.e2) AS c2 FROM g1) v1 CROSS JOIN (SELECT AVG(DISTINCT g1.e4) AS c3 FROM g1) v2", sqlVisitor.toString());
obj = commandBuilder.getCommand("select count(distinct pm1.g1.e1), 1, count(distinct pm1.g1.e2), avg(distinct pm1.g1.e4) from pm1.g1 where pm1.g1.e3 = true");
sqlVisitor = impalaTranslator.getSQLConversionVisitor();
sqlVisitor.append(obj);
assertEquals("SELECT v0.c0, v0.c1, v1.c2, v2.c3 FROM (SELECT COUNT(DISTINCT g1.e1) AS c0, 1 AS c1 FROM g1 WHERE g1.e3 = true) v0 CROSS JOIN (SELECT COUNT(DISTINCT g1.e2) AS c2 FROM g1 WHERE g1.e3 = true) v1 CROSS JOIN (SELECT AVG(DISTINCT g1.e4) AS c3 FROM g1 WHERE g1.e3 = true) v2", sqlVisitor.toString());
}
Aggregations