use of org.teiid.translator.simpledb.SimpleDBSQLVisitor in project teiid by teiid.
the class TestSimpleDBSQLVisitor method testEvery2.
@Test
public void testEvery2() 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.every(attribute) = '1' or simpledb.every(attribute) = '2'");
SimpleDBSQLVisitor visitor = new SimpleDBSQLVisitor();
visitor.append(c);
assertEquals("SELECT attribute FROM item WHERE SIMPLEDB.EVERY(attribute) IN ('2', '1')", visitor.toString());
}
use of org.teiid.translator.simpledb.SimpleDBSQLVisitor in project teiid by teiid.
the class TestSimpleDBSQLVisitor method testNE.
@Test
public void testNE() 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'");
SimpleDBSQLVisitor visitor = new SimpleDBSQLVisitor();
visitor.append(c);
assertEquals("SELECT itemName() FROM item WHERE itemName() != 'name'", visitor.toString());
}
use of org.teiid.translator.simpledb.SimpleDBSQLVisitor in project teiid by teiid.
the class TestSimpleDBSQLVisitor method testEveryLike.
@Test
public void testEveryLike() 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.every(attribute) like '1%'");
SimpleDBSQLVisitor visitor = new SimpleDBSQLVisitor();
visitor.append(c);
assertEquals("SELECT attribute FROM item WHERE SIMPLEDB.EVERY(attribute) LIKE '1%'", visitor.toString());
}
use of org.teiid.translator.simpledb.SimpleDBSQLVisitor in project teiid by teiid.
the class TestSimpleDBSQLVisitor method testSelectCountStar.
@Test
public void testSelectCountStar() 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 count(*) from item");
SimpleDBSQLVisitor visitor = new SimpleDBSQLVisitor();
visitor.append(c);
assertEquals("SELECT COUNT(*) FROM item", visitor.toString());
assertEquals(Arrays.asList("Count"), visitor.getProjectedColumns());
}
Aggregations