use of org.teiid.query.function.FunctionTree 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.query.function.FunctionTree 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.query.function.FunctionTree in project teiid by teiid.
the class TestProtobufMetadataProcessor method getTransformationMetadata.
public static TransformationMetadata getTransformationMetadata(MetadataFactory mf, InfinispanExecutionFactory ef) throws Exception {
TransformationMetadata metadata = RealMetadataFactory.createTransformationMetadata(mf.asMetadataStore(), "proto", new FunctionTree("foo", new UDFSource(ef.getPushDownFunctions())));
ValidatorReport report = new MetadataValidator().validate(metadata.getVdbMetaData(), metadata.getMetadataStore());
if (report.hasItems()) {
throw new RuntimeException(report.getFailureMessage());
}
return metadata;
}
use of org.teiid.query.function.FunctionTree in project teiid by teiid.
the class TestFunctionPushdown method testMustPushdownOverMultipleSources.
@Test
public void testMustPushdownOverMultipleSources() throws Exception {
QueryMetadataInterface metadata = RealMetadataFactory.createTransformationMetadata(RealMetadataFactory.example1Cached().getMetadataStore(), "example1", new FunctionTree("foo", new FakeFunctionMetadataSource()));
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setFunctionSupport("misc.namespace.func", true);
// $NON-NLS-1$
capFinder.addCapabilities("pm1", caps);
// $NON-NLS-1$
capFinder.addCapabilities("pm2", caps);
// $NON-NLS-1$
String sql = "select func(x.e1) from pm1.g1 as x, pm2.g1 as y where x.e2 = y.e2";
ProcessorPlan plan = helpPlan(sql, metadata, null, capFinder, new String[] { "SELECT g_0.e2 AS c_0, func(g_0.e1) AS c_1 FROM pm1.g1 AS g_0 ORDER BY c_0", "SELECT g_0.e2 AS c_0 FROM pm2.g1 AS g_0 ORDER BY c_0" }, // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
HardcodedDataManager dataManager = new HardcodedDataManager();
dataManager.addData("SELECT g_0.e2 AS c_0, func(g_0.e1) AS c_1 FROM pm1.g1 AS g_0 ORDER BY c_0", new List[] { Arrays.asList(1, "a") });
dataManager.addData("SELECT g_0.e2 AS c_0 FROM pm2.g1 AS g_0 ORDER BY c_0", new List[] { Arrays.asList(1), Arrays.asList(2) });
CommandContext cc = TestProcessor.createCommandContext();
cc.setMetadata(metadata);
TestProcessor.helpProcess(plan, cc, dataManager, new List[] { Arrays.asList("a") });
}
use of org.teiid.query.function.FunctionTree in project teiid by teiid.
the class TestQueryRewriter method testUDFParse.
@Test
public void testUDFParse() throws Exception {
QueryMetadataInterface metadata = RealMetadataFactory.createTransformationMetadata(RealMetadataFactory.example1Cached().getMetadataStore(), "example1", new FunctionTree("foo", new FakeFunctionMetadataSource()));
String sql = "parsedate_(pm1.g1.e1) = {d'2001-01-01'}";
helpTestRewriteCriteria(sql, parseCriteria(sql, metadata), metadata);
}
Aggregations