Search in sources :

Example 26 with QueryMetadataInterface

use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.

the class TestMultiSourcePlanToProcessConverter method testAggNotParitioned.

@Test
public void testAggNotParitioned() throws Exception {
    QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "SELECT max(phys.a) FROM MultiModel.Phys";
    // $NON-NLS-1$
    final String multiModel = "MultiModel";
    final int sources = 2;
    final List<?>[] expected = new List<?>[] { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Arrays.asList("y") };
    final HardcodedDataManager dataMgr = new HardcodedDataManager();
    // $NON-NLS-1$
    dataMgr.addData(// $NON-NLS-1$
    "SELECT MAX(g_0.a) FROM MultiModel.Phys AS g_0", new List<?>[] { Arrays.asList("y") });
    ProcessorPlan plan = helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB());
    TestOptimizer.checkNodeTypes(plan, new int[] { // Access
    3, // 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 : HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) List(java.util.List) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 27 with QueryMetadataInterface

use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.

the class TestMultiSourcePlanToProcessConverter method testMultiReplacementWithLimit1.

@Test
public void testMultiReplacementWithLimit1() throws Exception {
    final QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "SELECT a, b FROM MultiModel.Phys limit 1, 1";
    // $NON-NLS-1$
    final String multiModel = "MultiModel";
    final int sources = 2;
    final List<?>[] expected = new List<?>[] { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Arrays.asList("x", "z") };
    final HardcodedDataManager dataMgr = new HardcodedDataManager();
    // $NON-NLS-1$
    dataMgr.addData(// $NON-NLS-1$
    "SELECT g_0.a AS c_0, g_0.b AS c_1 FROM MultiModel.Phys AS g_0 LIMIT 2", new List<?>[] { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Arrays.asList("y", "z"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Arrays.asList("x", "z") });
    RelationalPlan plan = (RelationalPlan) helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB());
    assertTrue(plan.getRootNode() instanceof LimitNode);
}
Also used : HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) LimitNode(org.teiid.query.processor.relational.LimitNode) List(java.util.List) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) RelationalPlan(org.teiid.query.processor.relational.RelationalPlan) Test(org.junit.Test)

Example 28 with QueryMetadataInterface

use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.

the class TestAuthorizationValidationVisitor method testFunction.

@Test
public void testFunction() throws Exception {
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    // $NON-NLS-1$
    helpTest("SELECT e1 FROM pm1.g1 where xyz() > 0", metadata, new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1);
    // $NON-NLS-1$
    helpTest("SELECT e1, curdate() FROM pm1.g2 where xyz() > 0", metadata, new String[] { "xyz()" }, RealMetadataFactory.example1VDB(), exampleAuthSvc2);
}
Also used : QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Example 29 with QueryMetadataInterface

use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.

the class TestOptimizer method testPushFunctionInSelect2.

@Test
public void testPushFunctionInSelect2() {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = new BasicSourceCapabilities();
    caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
    caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
    caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
    caps.setFunctionSupport(SourceSystemFunctions.LCASE, true);
    // $NON-NLS-1$
    capFinder.addCapabilities("pm1", caps);
    // Add join capability to pm1
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    ProcessorPlan plan = helpPlan(// $NON-NLS-1$
    "SELECT lower(e1), upper(e1), e2 FROM pm1.g1 WHERE upper(e1) = 'X'", metadata, null, capFinder, // $NON-NLS-1$
    new String[] { "SELECT lower(e1), upper(e1), e2 FROM pm1.g1 WHERE ucase(e1) = 'X'" }, SHOULD_SUCCEED);
    checkNodeTypes(plan, FULL_PUSHDOWN);
}
Also used : FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 30 with QueryMetadataInterface

use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.

the class TestOptimizer method helpTestUnionPushdown.

public void helpTestUnionPushdown(boolean queryHasOrderBy, boolean hasUnionCapability, boolean hasUnionOrderByCapability) {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = new BasicSourceCapabilities();
    caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
    caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
    caps.setCapabilitySupport(Capability.QUERY_UNION, hasUnionCapability);
    caps.setCapabilitySupport((Capability.QUERY_ORDERBY), hasUnionOrderByCapability);
    caps.setCapabilitySupport((Capability.QUERY_SET_ORDER_BY), hasUnionOrderByCapability);
    // $NON-NLS-1$
    capFinder.addCapabilities("BQT1", caps);
    // $NON-NLS-1$
    String sqlUnion = "SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntKey FROM BQT1.SmallB";
    // $NON-NLS-1$
    String sqlOrderBy = sqlUnion + " ORDER BY IntKey";
    String sql = null;
    if (queryHasOrderBy) {
        sql = sqlOrderBy;
    } else {
        sql = sqlUnion;
    }
    String[] expectedSql = null;
    if (hasUnionCapability) {
        if (queryHasOrderBy && hasUnionOrderByCapability) {
            expectedSql = new String[] { sqlOrderBy };
        } else {
            expectedSql = new String[] { sqlUnion };
        }
    } else {
        // $NON-NLS-1$//$NON-NLS-2$
        expectedSql = new String[] { "SELECT IntKey FROM BQT1.SmallA", "SELECT IntKey FROM BQT1.SmallB" };
    }
    QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
    ProcessorPlan plan = helpPlan(sql, metadata, null, capFinder, expectedSql, SHOULD_SUCCEED);
    int accessCount = hasUnionCapability ? 1 : 2;
    int projectCount = 0;
    int sortCount = 0;
    if (queryHasOrderBy && !(hasUnionCapability && hasUnionOrderByCapability)) {
        sortCount = 1;
    }
    int unionCount = hasUnionCapability ? 0 : 1;
    checkNodeTypes(plan, new int[] { // Access
    accessCount, // DependentAccess
    0, // DependentSelect
    0, // DependentProject
    0, // DupRemove
    0, // Grouping
    0, // NestedLoopJoinStrategy
    0, // MergeJoinStrategy
    0, // Null
    0, // PlanExecution
    0, // Project
    projectCount, // Select
    0, // Sort
    sortCount, // UnionAll
    unionCount });
}
Also used : FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) ProcessorPlan(org.teiid.query.processor.ProcessorPlan)

Aggregations

QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)507 Test (org.junit.Test)464 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)210 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)189 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)177 List (java.util.List)126 Command (org.teiid.query.sql.lang.Command)90 ArrayList (java.util.ArrayList)72 FakeDataManager (org.teiid.query.processor.FakeDataManager)48 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)43 BigInteger (java.math.BigInteger)41 CommandContext (org.teiid.query.util.CommandContext)37 HardcodedDataManager (org.teiid.query.processor.HardcodedDataManager)29 AnalysisRecord (org.teiid.query.analysis.AnalysisRecord)16 MetadataStore (org.teiid.metadata.MetadataStore)12 Schema (org.teiid.metadata.Schema)11 BatchedUpdateCommand (org.teiid.query.sql.lang.BatchedUpdateCommand)11 TeiidException (org.teiid.core.TeiidException)10 TeiidProcessingException (org.teiid.core.TeiidProcessingException)10 CapabilitiesFinder (org.teiid.query.optimizer.capabilities.CapabilitiesFinder)10