Search in sources :

Example 51 with FunctionMethod

use of org.teiid.metadata.FunctionMethod in project teiid by teiid.

the class TestFunctionMethod method testEquivalence11.

@Test
public void testEquivalence11() {
    // $NON-NLS-1$ //$NON-NLS-2$
    FunctionParameter pout = new FunctionParameter("out", "string");
    FunctionMethod m1 = new // $NON-NLS-1$ //$NON-NLS-2$
    FunctionMethod(// $NON-NLS-1$ //$NON-NLS-2$
    "length", // $NON-NLS-1$ //$NON-NLS-2$
    "", // $NON-NLS-1$ //$NON-NLS-2$
    FunctionCategoryConstants.STRING, // $NON-NLS-1$ //$NON-NLS-2$
    "com.metamatrix.query.function.FunctionMethods", // $NON-NLS-1$ //$NON-NLS-2$
    "length", null, pout);
    UnitTestUtil.helpTestEquivalence(0, m1, m1);
}
Also used : FunctionMethod(org.teiid.metadata.FunctionMethod) FunctionParameter(org.teiid.metadata.FunctionParameter) Test(org.junit.Test)

Example 52 with FunctionMethod

use of org.teiid.metadata.FunctionMethod in project teiid by teiid.

the class ExecutionFactory method addPushDownFunction.

/**
 * Adds a pushdown function.
 * @param qualifier will be pre-pended to the name
 * @param name
 * @param returnType see {@link RUNTIME_NAMES} for type names
 * @param paramTypes see {@link RUNTIME_NAMES} for type names
 * @return the FunctionMethod created.
 */
protected FunctionMethod addPushDownFunction(String qualifier, String name, String returnType, String... paramTypes) {
    FunctionMethod method = FunctionMethod.createFunctionMethod(qualifier + '.' + name, name, qualifier, returnType, paramTypes);
    method.setNameInSource(name);
    pushdownFunctionMethods.add(method);
    return method;
}
Also used : FunctionMethod(org.teiid.metadata.FunctionMethod)

Example 53 with FunctionMethod

use of org.teiid.metadata.FunctionMethod in project teiid by teiid.

the class TestAggregateProcessing method testNullDependentAggParitioned.

@Test
public void testNullDependentAggParitioned() throws Exception {
    MetadataStore ms = RealMetadataFactory.example1Store();
    Schema s = ms.getSchemas().get("PM1");
    FunctionMethod fm = addAgg(s, "myagg", SumAll.class, DataTypeManager.DefaultDataTypes.INTEGER);
    fm.setNullOnNull(false);
    fm.getAggregateAttributes().setDecomposable(true);
    TransformationMetadata metadata = RealMetadataFactory.createTransformationMetadata(ms, "test");
    // $NON-NLS-1$
    final String userSql = "SELECT myagg(e2), source_name FROM (select e2, 'a' as source_name from pm1.g1 union all select e2, 'b' from pm2.g1) x group by source_name";
    BasicSourceCapabilities caps = TestAggregatePushdown.getAggregateCapabilities();
    caps.setFunctionSupport("myagg", true);
    ProcessorPlan plan = TestOptimizer.helpPlan(userSql, metadata, new String[] { "SELECT myagg(ALL v_0.c_1), v_0.c_0 FROM (SELECT 'a' AS c_0, g_0.e2 AS c_1 FROM pm1.g1 AS g_0) AS v_0 GROUP BY v_0.c_0", "SELECT myagg(ALL v_0.c_1), v_0.c_0 FROM (SELECT 'b' AS c_0, g_0.e2 AS c_1 FROM pm2.g1 AS g_0) AS v_0 GROUP BY v_0.c_0" }, new DefaultCapabilitiesFinder(caps), ComparisonMode.EXACT_COMMAND_STRING);
    TestOptimizer.checkNodeTypes(plan, new int[] { // Access
    2, // DependentAccess
    0, // DependentSelect
    0, // DependentProject
    0, // DupRemove
    0, // Grouping
    0, // NestedLoopJoinStrategy
    0, // MergeJoinStrategy
    0, // Null
    0, // PlanExecution
    0, // Project
    1, // Select
    0, // Sort
    0, // UnionAll
    1 });
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) Schema(org.teiid.metadata.Schema) FunctionMethod(org.teiid.metadata.FunctionMethod) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 54 with FunctionMethod

use of org.teiid.metadata.FunctionMethod in project teiid by teiid.

the class TestAggregateProcessing method testNullDependentAgg.

@Test
public void testNullDependentAgg() throws Exception {
    MetadataStore ms = RealMetadataFactory.example1Store();
    Schema s = ms.getSchemas().get("PM1");
    FunctionMethod fm = addAgg(s, "myagg", SumAll.class, DataTypeManager.DefaultDataTypes.INTEGER);
    fm.setNullOnNull(false);
    fm.getAggregateAttributes().setDecomposable(true);
    TransformationMetadata metadata = RealMetadataFactory.createTransformationMetadata(ms, "test");
    // $NON-NLS-1$
    final String userSql = "SELECT myagg(e2) FROM (select e2, e1 as source_name from pm1.g1 union all select e2, e1 from pm2.g1) x";
    BasicSourceCapabilities caps = TestAggregatePushdown.getAggregateCapabilities();
    caps.setFunctionSupport("myagg", true);
    ProcessorPlan plan = TestOptimizer.helpPlan(userSql, metadata, new String[] { "SELECT myagg(ALL g_0.e2) FROM pm1.g1 AS g_0 HAVING COUNT(*) > 0", "SELECT myagg(ALL g_0.e2) FROM pm2.g1 AS g_0 HAVING COUNT(*) > 0" }, new DefaultCapabilitiesFinder(caps), ComparisonMode.EXACT_COMMAND_STRING);
    TestOptimizer.checkNodeTypes(plan, new int[] { // Access
    2, // DependentAccess
    0, // DependentSelect
    0, // DependentProject
    0, // DupRemove
    0, // Grouping
    1, // NestedLoopJoinStrategy
    0, // MergeJoinStrategy
    0, // Null
    0, // PlanExecution
    0, // Project
    1, // Select
    0, // Sort
    0, // UnionAll
    1 });
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) Schema(org.teiid.metadata.Schema) FunctionMethod(org.teiid.metadata.FunctionMethod) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 55 with FunctionMethod

use of org.teiid.metadata.FunctionMethod in project teiid by teiid.

the class TestAggregateProcessing method testNullDependentAgg1.

@Test
public void testNullDependentAgg1() throws Exception {
    MetadataStore ms = RealMetadataFactory.example1Store();
    Schema s = ms.getSchemas().get("PM1");
    FunctionMethod fm = addAgg(s, "myagg", CustomSum.class, DataTypeManager.DefaultDataTypes.STRING);
    fm.setNullOnNull(false);
    fm.getAggregateAttributes().setDecomposable(true);
    TransformationMetadata metadata = RealMetadataFactory.createTransformationMetadata(ms, "test");
    // $NON-NLS-1$
    final String userSql = "SELECT myagg(e2) FROM (select e2, e1 as source_name from pm1.g1 union all select e2, e1 from pm2.g1) x";
    BasicSourceCapabilities caps = TestAggregatePushdown.getAggregateCapabilities();
    caps.setFunctionSupport("myagg", true);
    caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, false);
    ProcessorPlan plan = TestOptimizer.helpPlan(userSql, metadata, new String[] { "SELECT COUNT(*), myagg(ALL g_0.e2) FROM pm2.g1 AS g_0", "SELECT COUNT(*), myagg(ALL g_0.e2) FROM pm1.g1 AS g_0" }, new DefaultCapabilitiesFinder(caps), ComparisonMode.EXACT_COMMAND_STRING);
    TestOptimizer.checkNodeTypes(plan, new int[] { // Access
    2, // DependentAccess
    0, // DependentSelect
    0, // DependentProject
    0, // DupRemove
    0, // Grouping
    1, // NestedLoopJoinStrategy
    0, // MergeJoinStrategy
    0, // Null
    0, // PlanExecution
    0, // Project
    3, // Select
    2, // Sort
    0, // UnionAll
    1 });
    HardcodedDataManager dataManager = new HardcodedDataManager();
    dataManager.addData("SELECT COUNT(*), myagg(ALL g_0.e2) FROM pm1.g1 AS g_0", new List<?>[] { Arrays.asList(0, null) });
    dataManager.addData("SELECT COUNT(*), myagg(ALL g_0.e2) FROM pm2.g1 AS g_0", new List<?>[] { Arrays.asList(0, null) });
    // if we don't filter the nulls, then we'd get 0
    helpProcess(plan, dataManager, new List[] { Collections.singletonList(null) });
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) Schema(org.teiid.metadata.Schema) FunctionMethod(org.teiid.metadata.FunctionMethod) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Aggregations

FunctionMethod (org.teiid.metadata.FunctionMethod)63 FunctionParameter (org.teiid.metadata.FunctionParameter)31 Test (org.junit.Test)15 ArrayList (java.util.ArrayList)9 Schema (org.teiid.metadata.Schema)6 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)6 IOException (java.io.IOException)5 MetadataStore (org.teiid.metadata.MetadataStore)5 List (java.util.List)4 TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)4 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)4 Collection (java.util.Collection)3 HashMap (java.util.HashMap)3 LinkedList (java.util.LinkedList)3 XMLStreamException (javax.xml.stream.XMLStreamException)3 ConnectorManager (org.teiid.dqp.internal.datamgr.ConnectorManager)3 DeployVDBParameter (org.teiid.jdbc.FakeServer.DeployVDBParameter)3 AggregateAttributes (org.teiid.metadata.AggregateAttributes)3 Procedure (org.teiid.metadata.Procedure)3 UDFSource (org.teiid.query.function.UDFSource)3