use of org.teiid.query.function.FunctionTree in project teiid by teiid.
the class TableSystemTable method getChildren.
@Override
protected NavigableMap<String, FunctionMethod> getChildren(Schema s, TransformationMetadata metadata) {
// since there is no proper schema for a UDF model, no results will show up for legacy functions
if (s.getName().equals(CoreConstants.SYSTEM_MODEL)) {
// currently all system functions are contributed via alternative mechanisms
// system source, push down functions.
FunctionLibrary library = metadata.getFunctionLibrary();
FunctionTree tree = library.getSystemFunctions();
FunctionTree[] userFuncs = library.getUserFunctions();
TreeMap<String, FunctionMethod> functions = new TreeMap<String, FunctionMethod>(String.CASE_INSENSITIVE_ORDER);
for (FunctionTree userFunc : userFuncs) {
if (userFunc.getSchemaName().equals(CoreConstants.SYSTEM_MODEL)) {
functions.putAll(userFunc.getFunctionsByUuid());
}
}
functions.putAll(tree.getFunctionsByUuid());
return functions;
}
return s.getFunctions();
}
use of org.teiid.query.function.FunctionTree in project teiid by teiid.
the class TestProcessor method testPreparedStatementDefect15348b.
/**
* defect 15348
* @throws Exception
*/
@Test
public void testPreparedStatementDefect15348b() throws Exception {
// $NON-NLS-1$
String sql = "SELECT e1 from pm4.g1 where myrtrim(concat(?, 'a '))=e1";
// Create expected results
List[] expected = new List[] { // $NON-NLS-1$
Arrays.asList(new Object[] { "aa" }) };
// Construct data manager with data
FakeDataManager dataManager = new FakeDataManager();
sampleData2a(dataManager);
// Plan query
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
// $NON-NLS-1$
caps.setFunctionSupport("myrtrim", true);
// $NON-NLS-1$
caps.setFunctionSupport("concat", true);
// $NON-NLS-1$
capFinder.addCapabilities("pm4", caps);
QueryMetadataInterface metadata = RealMetadataFactory.createTransformationMetadata(RealMetadataFactory.example1Cached().getMetadataStore(), "example1", new FunctionTree("foo", new FakeFunctionMetadataSource(), true));
processPreparedStatement(sql, expected, dataManager, capFinder, metadata, Arrays.asList("a"));
}
use of org.teiid.query.function.FunctionTree in project teiid by teiid.
the class TestProcessor method testPreparedStatementDefect15348.
/**
* defect 15348
* @throws Exception
*/
@Test
public void testPreparedStatementDefect15348() throws Exception {
// $NON-NLS-1$
String sql = "SELECT e1 from pm1.g1 where myrtrim(?)=e1";
// Create expected results
List[] expected = new List[] { // $NON-NLS-1$
Arrays.asList(new Object[] { "a" }) };
// Construct data manager with data
FakeDataManager dataManager = new FakeDataManager();
sampleData2a(dataManager);
// Plan query
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
// $NON-NLS-1$
caps.setFunctionSupport("myrtrim", true);
// $NON-NLS-1$
capFinder.addCapabilities("pm1", caps);
QueryMetadataInterface metadata = RealMetadataFactory.createTransformationMetadata(RealMetadataFactory.example1Cached().getMetadataStore(), "example1", new FunctionTree("foo", new FakeFunctionMetadataSource(), true));
processPreparedStatement(sql, expected, dataManager, capFinder, metadata, Arrays.asList("a "));
}
use of org.teiid.query.function.FunctionTree in project teiid by teiid.
the class TestResolver method testNamespacedFunction.
@Test
public void testNamespacedFunction() throws Exception {
// $NON-NLS-1$
String sql = "SELECT namespace.func('e1') FROM vm1.g1 ";
QueryMetadataInterface metadata = RealMetadataFactory.createTransformationMetadata(RealMetadataFactory.example1Cached().getMetadataStore(), "example1", new FunctionTree("foo", new FakeFunctionMetadataSource()));
Query command = (Query) helpParse(sql);
QueryResolver.resolveCommand(command, metadata);
command = (Query) helpParse("SELECT func('e1') FROM vm1.g1 ");
QueryResolver.resolveCommand(command, metadata);
}
use of org.teiid.query.function.FunctionTree in project teiid by teiid.
the class TestFunctionPushdown method testMustPushdownOverMultipleSourcesWithViewDupRemoval.
@Test
public void testMustPushdownOverMultipleSourcesWithViewDupRemoval() 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 (select distinct x.* from pm1.g1 as x, pm2.g1 as y where x.e2 = y.e2 order by e1 limit 10) as x";
helpPlan(sql, metadata, null, capFinder, new String[] {}, // $NON-NLS-1$
ComparisonMode.FAILED_PLANNING);
}
Aggregations