Search in sources :

Example 11 with Annotation

use of org.teiid.client.plan.Annotation in project teiid by teiid.

the class TestMaterialization method testMaterializedTransformationNoCache2.

// related to defect 14423
@Test
public void testMaterializedTransformationNoCache2() throws Exception {
    // $NON-NLS-1$
    String userSql = "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE";
    QueryMetadataInterface metadata = RealMetadataFactory.exampleMaterializedView();
    AnalysisRecord analysis = new AnalysisRecord(true, DEBUG);
    Command command = helpGetCommand(userSql, metadata, null);
    // $NON-NLS-1$
    TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] { "SELECT g_0.x FROM MatSrc.MatSrc AS g_0" }, ComparisonMode.EXACT_COMMAND_STRING);
    Collection<Annotation> annotations = analysis.getAnnotations();
    // $NON-NLS-1$
    assertNotNull("Expected annotations but got none", annotations);
    // $NON-NLS-1$
    assertTrue("Expected one annotation", annotations.size() == 1);
    // $NON-NLS-1$
    assertEquals("Expected catagory mat view", annotations.iterator().next().getCategory(), Annotation.MATERIALIZED_VIEW);
}
Also used : AnalysisRecord(org.teiid.query.analysis.AnalysisRecord) Command(org.teiid.query.sql.lang.Command) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Annotation(org.teiid.client.plan.Annotation) Test(org.junit.Test)

Example 12 with Annotation

use of org.teiid.client.plan.Annotation in project teiid by teiid.

the class TestMaterialization method testDefaultMaterialization.

@Test
public void testDefaultMaterialization() throws Exception {
    // $NON-NLS-1$
    String userSql = "SELECT * from vgroup2";
    TransformationMetadata metadata = RealMetadataFactory.exampleMaterializedView();
    AnalysisRecord analysis = new AnalysisRecord(true, DEBUG);
    Command command = helpGetCommand(userSql, metadata, null);
    CommandContext cc = new CommandContext();
    GlobalTableStoreImpl gts = new GlobalTableStoreImpl(null, metadata.getVdbMetaData(), metadata);
    cc.setGlobalTableStore(gts);
    ProcessorPlan plan = TestOptimizer.getPlan(command, metadata, getGenericFinder(), analysis, true, cc);
    TestOptimizer.checkAtomicQueries(new String[] { "SELECT #MAT_MATVIEW.VGROUP2.x FROM #MAT_MATVIEW.VGROUP2" }, plan);
    Collection<Annotation> annotations = analysis.getAnnotations();
    // $NON-NLS-1$
    assertNotNull("Expected annotations but got none", annotations);
    // $NON-NLS-1$
    assertEquals("Expected one annotation", 1, annotations.size());
    // $NON-NLS-1$
    assertEquals("Expected catagory mat view", annotations.iterator().next().getCategory(), Annotation.MATERIALIZED_VIEW);
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) AnalysisRecord(org.teiid.query.analysis.AnalysisRecord) CommandContext(org.teiid.query.util.CommandContext) Command(org.teiid.query.sql.lang.Command) GlobalTableStoreImpl(org.teiid.query.tempdata.GlobalTableStoreImpl) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Annotation(org.teiid.client.plan.Annotation) Test(org.junit.Test)

Example 13 with Annotation

use of org.teiid.client.plan.Annotation in project teiid by teiid.

the class TestMaterialization method testDefaultMaterializationWithCacheHint.

@Test
public void testDefaultMaterializationWithCacheHint() throws Exception {
    // $NON-NLS-1$
    String userSql = "SELECT * from vgroup4";
    TransformationMetadata metadata = RealMetadataFactory.exampleMaterializedView();
    AnalysisRecord analysis = new AnalysisRecord(true, DEBUG);
    Command command = helpGetCommand(userSql, metadata, null);
    CommandContext cc = new CommandContext();
    GlobalTableStoreImpl gts = new GlobalTableStoreImpl(null, metadata.getVdbMetaData(), metadata);
    cc.setGlobalTableStore(gts);
    ProcessorPlan plan = TestOptimizer.getPlan(command, metadata, getGenericFinder(), analysis, true, cc);
    TestOptimizer.checkAtomicQueries(new String[] { "SELECT #MAT_MATVIEW.VGROUP4.x FROM #MAT_MATVIEW.VGROUP4" }, plan);
    Collection<Annotation> annotations = analysis.getAnnotations();
    // $NON-NLS-1$
    assertNotNull("Expected annotations but got none", annotations);
    // $NON-NLS-1$
    assertEquals("Expected one annotation", 1, annotations.size());
    // $NON-NLS-1$
    assertEquals("Expected catagory mat view", annotations.iterator().next().getCategory(), Annotation.MATERIALIZED_VIEW);
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) AnalysisRecord(org.teiid.query.analysis.AnalysisRecord) CommandContext(org.teiid.query.util.CommandContext) Command(org.teiid.query.sql.lang.Command) GlobalTableStoreImpl(org.teiid.query.tempdata.GlobalTableStoreImpl) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Annotation(org.teiid.client.plan.Annotation) Test(org.junit.Test)

Example 14 with Annotation

use of org.teiid.client.plan.Annotation in project teiid by teiid.

the class TestMaterialization method testDefaultMaterializationWithPK.

@Test
public void testDefaultMaterializationWithPK() throws Exception {
    // $NON-NLS-1$
    String userSql = "SELECT * from vgroup3 where x = 'foo'";
    TransformationMetadata metadata = RealMetadataFactory.exampleMaterializedView();
    AnalysisRecord analysis = new AnalysisRecord(true, DEBUG);
    Command command = helpGetCommand(userSql, metadata, null);
    CommandContext cc = new CommandContext();
    GlobalTableStoreImpl gts = new GlobalTableStoreImpl(null, metadata.getVdbMetaData(), metadata);
    cc.setGlobalTableStore(gts);
    RelationalPlan plan = (RelationalPlan) TestOptimizer.getPlan(command, metadata, getGenericFinder(), analysis, true, cc);
    assertEquals(1f, plan.getRootNode().getEstimateNodeCardinality());
    TestOptimizer.checkAtomicQueries(new String[] { "SELECT #MAT_MATVIEW.VGROUP3.x, #MAT_MATVIEW.VGROUP3.y FROM #MAT_MATVIEW.VGROUP3 WHERE #MAT_MATVIEW.VGROUP3.x = 'foo'" }, plan);
    Collection<Annotation> annotations = analysis.getAnnotations();
    // $NON-NLS-1$
    assertNotNull("Expected annotations but got none", annotations);
    // $NON-NLS-1$
    assertEquals("Expected one annotation", 1, annotations.size());
    // $NON-NLS-1$
    assertEquals("Expected catagory mat view", annotations.iterator().next().getCategory(), Annotation.MATERIALIZED_VIEW);
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) AnalysisRecord(org.teiid.query.analysis.AnalysisRecord) CommandContext(org.teiid.query.util.CommandContext) Command(org.teiid.query.sql.lang.Command) GlobalTableStoreImpl(org.teiid.query.tempdata.GlobalTableStoreImpl) RelationalPlan(org.teiid.query.processor.relational.RelationalPlan) Annotation(org.teiid.client.plan.Annotation) Test(org.junit.Test)

Aggregations

Annotation (org.teiid.client.plan.Annotation)14 Test (org.junit.Test)9 AnalysisRecord (org.teiid.query.analysis.AnalysisRecord)9 Command (org.teiid.query.sql.lang.Command)9 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)6 RelationalPlan (org.teiid.query.processor.relational.RelationalPlan)4 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)3 GlobalTableStoreImpl (org.teiid.query.tempdata.GlobalTableStoreImpl)3 CommandContext (org.teiid.query.util.CommandContext)3 PlanNode (org.teiid.query.optimizer.relational.plantree.PlanNode)2 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Ignore (org.junit.Ignore)1 QueryPlannerException (org.teiid.api.exception.query.QueryPlannerException)1 PlanNode (org.teiid.client.plan.PlanNode)1 SQLXMLImpl (org.teiid.core.types.SQLXMLImpl)1 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)1