Search in sources :

Example 96 with Command

use of org.teiid.query.sql.lang.Command in project teiid by teiid.

the class TestMaterialization method testMaterializedTransformationNoCache.

@Test
public void testMaterializedTransformationNoCache() throws Exception {
    // $NON-NLS-1$
    String userSql = "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE MatView.MatView";
    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 97 with Command

use of org.teiid.query.sql.lang.Command in project teiid by teiid.

the class TestMaterialization method testNoCacheCascade.

@Test
public void testNoCacheCascade() throws Exception {
    // $NON-NLS-1$
    String userSql = "SELECT MATVIEW1.E1 FROM MATVIEW1 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 WHERE g_0.x = '1'" }, ComparisonMode.EXACT_COMMAND_STRING);
}
Also used : AnalysisRecord(org.teiid.query.analysis.AnalysisRecord) Command(org.teiid.query.sql.lang.Command) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Example 98 with Command

use of org.teiid.query.sql.lang.Command in project teiid by teiid.

the class TestMaterialization method testTableNoCacheDoesntCascade.

@Test
public void testTableNoCacheDoesntCascade() throws Exception {
    // $NON-NLS-1$
    String userSql = "SELECT MATVIEW1.E1 FROM MATVIEW1 option nocache matview.matview1";
    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.e1 FROM MatTable.MatTable AS g_0 WHERE g_0.e1 = '1'" }, ComparisonMode.EXACT_COMMAND_STRING);
}
Also used : AnalysisRecord(org.teiid.query.analysis.AnalysisRecord) Command(org.teiid.query.sql.lang.Command) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Example 99 with Command

use of org.teiid.query.sql.lang.Command in project teiid by teiid.

the class TestMaterialization method testManagedMaterializedTransformationJoin.

@Test
public void testManagedMaterializedTransformationJoin() throws Exception {
    // make sure view removal is not inhibited
    // $NON-NLS-1$
    String userSql = "SELECT MatTable1.*,ManagedMatView.* FROM ManagedMatView left outer join MatTable1 on ManagedMatView.e1 = MatTable1.e1";
    QueryMetadataInterface metadata = RealMetadataFactory.exampleMaterializedView();
    AnalysisRecord analysis = new AnalysisRecord(true, DEBUG);
    Command command = helpGetCommand(userSql, metadata, null);
    TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] { // $NON-NLS-1$
    "SELECT g_1.e1, g_0.e1 FROM MatTable.MatTable AS g_0 LEFT OUTER JOIN MatTable.MatTable1 AS g_1 ON g_0.e1 = g_1.e1 WHERE mvstatus('MatView', 'ManagedMatView') = 1" }, ComparisonMode.EXACT_COMMAND_STRING);
}
Also used : AnalysisRecord(org.teiid.query.analysis.AnalysisRecord) Command(org.teiid.query.sql.lang.Command) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Example 100 with Command

use of org.teiid.query.sql.lang.Command in project teiid by teiid.

the class TestCriteriaCapabilityValidatorVisitor method helpTestVisitorWithCommand.

// Assume there is a wrapped command - this will allow subqueries to be properly resolved
public void helpTestVisitorWithCommand(String sql, Object modelID, TransformationMetadata metadata, CapabilitiesFinder capFinder, boolean isValid, boolean expectException) {
    try {
        Command command = QueryParser.getQueryParser().parseCommand(sql);
        QueryResolver.resolveCommand(command, metadata);
        // $NON-NLS-1$
        assertEquals("Got incorrect isValid flag", isValid, CriteriaCapabilityValidatorVisitor.canPushLanguageObject(command, modelID, metadata, capFinder, null));
    } catch (QueryMetadataException e) {
        if (!expectException) {
            throw new RuntimeException(e);
        }
    } catch (TeiidException e) {
        throw new RuntimeException(e);
    }
}
Also used : Command(org.teiid.query.sql.lang.Command) QueryMetadataException(org.teiid.api.exception.query.QueryMetadataException) TeiidException(org.teiid.core.TeiidException)

Aggregations

Command (org.teiid.query.sql.lang.Command)232 Test (org.junit.Test)142 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)90 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)73 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)66 List (java.util.List)64 CommandContext (org.teiid.query.util.CommandContext)38 ArrayList (java.util.ArrayList)37 BatchedUpdateCommand (org.teiid.query.sql.lang.BatchedUpdateCommand)36 BigInteger (java.math.BigInteger)29 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)25 AnalysisRecord (org.teiid.query.analysis.AnalysisRecord)21 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)20 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)19 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)16 LinkedList (java.util.LinkedList)10 QueryParser (org.teiid.query.parser.QueryParser)10 RelationalPlan (org.teiid.query.processor.relational.RelationalPlan)10 QueryCommand (org.teiid.query.sql.lang.QueryCommand)10 StoredProcedure (org.teiid.query.sql.lang.StoredProcedure)10