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);
}
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);
}
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);
}
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);
}
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);
}
}
Aggregations