use of org.teiid.cdk.api.TranslationUtility 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.cdk.api.TranslationUtility 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.cdk.api.TranslationUtility 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());
}
use of org.teiid.cdk.api.TranslationUtility in project teiid by teiid.
the class TestIckleConversionVisitor method helpUpdate.
private void helpUpdate(MetadataFactory mf, String query, String expected) throws Exception {
InfinispanExecutionFactory ef = new InfinispanExecutionFactory();
TransformationMetadata metadata = TestProtobufMetadataProcessor.getTransformationMetadata(mf, ef);
TranslationUtility utility = new TranslationUtility(metadata);
Command cmd = utility.parseCommand(query);
InfinispanUpdateVisitor visitor = new InfinispanUpdateVisitor(new RuntimeMetadataImpl(metadata));
visitor.append(cmd);
String actual = null;
if (cmd instanceof Update) {
actual = visitor.getUpdateQuery();
} else {
actual = visitor.getDeleteQuery();
}
assertEquals(expected, actual);
}
use of org.teiid.cdk.api.TranslationUtility in project teiid by teiid.
the class TestTeiidTableMarsheller method helpExecute.
private IckleConversionVisitor helpExecute(String query) throws Exception {
MetadataFactory mf = TestProtobufMetadataProcessor.protoMatadata("tables.proto");
// System.out.println(DDLStringVisitor.getDDLString(mf.getSchema(), null, null));
InfinispanExecutionFactory ef = new InfinispanExecutionFactory();
TransformationMetadata metadata = TestProtobufMetadataProcessor.getTransformationMetadata(mf, ef);
TranslationUtility utility = new TranslationUtility(metadata);
Select cmd = (Select) utility.parseCommand(query);
RuntimeMetadata runtimeMetadata = new RuntimeMetadataImpl(metadata);
IckleConversionVisitor visitor = new IckleConversionVisitor(runtimeMetadata, false);
visitor.visitNode(cmd);
visitor.getQuery();
return visitor;
}
Aggregations