use of org.teiid.translator.simpledb.SimpleDBSQLVisitor in project teiid by teiid.
the class TestSimpleDBSQLVisitor method testIntersection.
@Test
public void testIntersection() throws Exception {
SimpleDBExecutionFactory translator = new SimpleDBExecutionFactory();
translator.start();
MetadataFactory mf = TestDDLParser.helpParse("create foreign table item (\"itemName()\" integer, attribute string[]);", "y");
TransformationMetadata metadata = RealMetadataFactory.createTransformationMetadata(mf.asMetadataStore(), "x", new FunctionTree("foo", new UDFSource(translator.getPushDownFunctions())));
TranslationUtility tu = new TranslationUtility(metadata);
Command c = tu.parseCommand("select * from item where simpledb.intersection(attribute,'1', '2')");
SimpleDBSQLVisitor visitor = new SimpleDBSQLVisitor();
visitor.append(c);
assertEquals("SELECT attribute FROM item WHERE attribute = '1' INTERSECTION attribute = '2'", visitor.toString());
}
use of org.teiid.translator.simpledb.SimpleDBSQLVisitor in project teiid by teiid.
the class TestSimpleDBSQLVisitor method testOrderBy.
@Test(expected = TranslatorException.class)
public void testOrderBy() throws Exception {
TransformationMetadata tm = RealMetadataFactory.fromDDL("create foreign table item (\"itemName()\" string, attribute string);", "x", "y");
TranslationUtility tu = new TranslationUtility(tm);
Command c = tu.parseCommand("select * from item order by \"itemName()\"");
SimpleDBSQLVisitor visitor = new SimpleDBSQLVisitor();
visitor.append(c);
visitor.checkExceptions();
assertEquals("SELECT attribute FROM item ORDER BY itemName()", visitor.toString());
}
use of org.teiid.translator.simpledb.SimpleDBSQLVisitor in project teiid by teiid.
the class TestSimpleDBSQLVisitor method testSelect.
@Test
public void testSelect() throws Exception {
TransformationMetadata tm = RealMetadataFactory.fromDDL("create foreign table item (\"itemName()\" string, attribute string);", "x", "y");
TranslationUtility tu = new TranslationUtility(tm);
Command c = tu.parseCommand("select \"itemname()\" from item");
SimpleDBSQLVisitor visitor = new SimpleDBSQLVisitor();
visitor.append(c);
assertEquals("SELECT itemName() FROM item", visitor.toString());
c = tu.parseCommand("select \"itemname()\", attribute from item");
visitor = new SimpleDBSQLVisitor();
visitor.append(c);
assertEquals("SELECT attribute FROM item", visitor.toString());
assertEquals(2, visitor.getProjectedColumns().size());
}
use of org.teiid.translator.simpledb.SimpleDBSQLVisitor in project teiid by teiid.
the class TestSimpleDBSQLVisitor method testIntersection2.
@Test
public void testIntersection2() throws Exception {
SimpleDBExecutionFactory translator = new SimpleDBExecutionFactory();
translator.start();
MetadataFactory mf = TestDDLParser.helpParse("create foreign table item (\"itemName()\" integer, attribute string[]);", "y");
TransformationMetadata metadata = RealMetadataFactory.createTransformationMetadata(mf.asMetadataStore(), "x", new FunctionTree("foo", new UDFSource(translator.getPushDownFunctions())));
TranslationUtility tu = new TranslationUtility(metadata);
Command c = tu.parseCommand("select * from item where simpledb.intersection(attribute,'1', '2', '3') = true");
SimpleDBSQLVisitor visitor = new SimpleDBSQLVisitor();
visitor.append(c);
assertEquals("SELECT attribute FROM item WHERE attribute = '1' INTERSECTION attribute = '2' INTERSECTION attribute = '3'", visitor.toString());
}
use of org.teiid.translator.simpledb.SimpleDBSQLVisitor in project teiid by teiid.
the class TestSimpleDBSQLVisitor method testComparisionWithOR.
@Test
public void testComparisionWithOR() throws Exception {
TransformationMetadata tm = RealMetadataFactory.fromDDL("create foreign table item (\"itemName()\" string, attribute string);", "x", "y");
TranslationUtility tu = new TranslationUtility(tm);
Command c = tu.parseCommand("select \"itemname()\" from item where \"itemname()\" > 'name' and attribute < 'name'");
SimpleDBSQLVisitor visitor = new SimpleDBSQLVisitor();
visitor.append(c);
assertEquals("SELECT itemName() FROM item WHERE itemName() > 'name' AND attribute < 'name'", visitor.toString());
}
Aggregations