use of org.teiid.query.analysis.AnalysisRecord in project teiid by teiid.
the class TestResolver method testProcParamComparison_defect13653.
@Test
public void testProcParamComparison_defect13653() {
// $NON-NLS-1$
String userSql = "SELECT * FROM (EXEC mmspTest1.MMSP5('a')) AS a, (EXEC mmsptest1.mmsp6('b')) AS b";
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
AnalysisRecord analysis = AnalysisRecord.createNonRecordingRecord();
Query query = (Query) helpResolve(userSql, metadata);
From from = query.getFrom();
Collection fromClauses = from.getClauses();
SPParameter[] params = new SPParameter[2];
Iterator iter = fromClauses.iterator();
while (iter.hasNext()) {
SubqueryFromClause clause = (SubqueryFromClause) iter.next();
StoredProcedure proc = (StoredProcedure) clause.getCommand();
for (SPParameter param : proc.getParameters()) {
if (param.getParameterType() == ParameterInfo.IN) {
if (params[0] == null) {
params[0] = param;
} else {
params[1] = param;
}
}
}
}
// $NON-NLS-1$
assertTrue("Params should be not equal", !params[0].equals(params[1]));
}
use of org.teiid.query.analysis.AnalysisRecord in project teiid by teiid.
the class TestDependentJoins method testNoFullDepJoin.
@Test
public void testNoFullDepJoin() throws Exception {
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setCapabilitySupport(Capability.FULL_DEPENDENT_JOIN, true);
String sql = "select pm1.g1.e1, pm1.g1.e2, pm2.g1.e2 FROM pm1.g1, pm2.g1 where (pm1.g1.e1 = pm2.g1.e1) option makedep pm1.g1(no join)";
assertEquals("SELECT pm1.g1.e1, pm1.g1.e2, pm2.g1.e2 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e1 = pm2.g1.e1 OPTION MAKEDEP pm1.g1(NO JOIN)", QueryParser.getQueryParser().parseCommand(sql).toString());
// pass a debug analysisrecord to test debug annotations
TestOptimizer.helpPlanCommand(TestOptimizer.helpGetCommand(sql, TestOptimizer.example1(), null), TestOptimizer.example1(), new DefaultCapabilitiesFinder(caps), new AnalysisRecord(true, true), new String[] { "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1 FROM pm2.g1 AS g_0 ORDER BY c_0", "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1 FROM pm1.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>) ORDER BY c_0" }, // $NON-NLS-1$ //$NON-NLS-2$
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
}
use of org.teiid.query.analysis.AnalysisRecord in project teiid by teiid.
the class TestMaterialization method testManagedMaterializedTransformationSubquery.
@Test
public void testManagedMaterializedTransformationSubquery() throws Exception {
// $NON-NLS-1$
String userSql = "SELECT e1, (select min(e1) from ManagedMatView x where x.e1 > MatTable1.e1) FROM MatTable1";
QueryMetadataInterface metadata = RealMetadataFactory.exampleMaterializedView();
AnalysisRecord analysis = new AnalysisRecord(true, DEBUG);
Command command = helpGetCommand(userSql, metadata, null);
BasicSourceCapabilities capabilities = getTypicalCapabilities();
capabilities.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
capabilities.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
capabilities.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR_PROJECTION, true);
capabilities.setCapabilitySupport(Capability.QUERY_AGGREGATES_MIN, true);
TestOptimizer.helpPlanCommand(command, metadata, new DefaultCapabilitiesFinder(capabilities), analysis, new String[] { // $NON-NLS-1$
"SELECT g_0.e1, (SELECT MIN(g_1.e1) FROM MatTable.MatTable AS g_1 WHERE (mvstatus('MatView', 'ManagedMatView') = 1) AND (g_1.e1 > g_0.e1)) FROM MatTable.MatTable1 AS g_0" }, ComparisonMode.EXACT_COMMAND_STRING);
}
use of org.teiid.query.analysis.AnalysisRecord in project teiid by teiid.
the class TestMaterialization method testManagedMaterializedTransformationInsert.
@Test
public void testManagedMaterializedTransformationInsert() throws Exception {
// $NON-NLS-1$
String userSql = "insert into MatTable1 SELECT * FROM ManagedMatView option nocache ManagedMatView";
QueryMetadataInterface metadata = RealMetadataFactory.exampleMaterializedView();
AnalysisRecord analysis = new AnalysisRecord(true, DEBUG);
Command command = helpGetCommand(userSql, metadata, null);
BasicSourceCapabilities bsc = TestOptimizer.getTypicalCapabilities();
RelationalPlan plan = (RelationalPlan) TestOptimizer.helpPlanCommand(command, metadata, new DefaultCapabilitiesFinder(bsc), analysis, new String[] { // $NON-NLS-1$
"SELECT g_0.e1 FROM MatTable.MatTable AS g_0 WHERE mvstatus('MatView', 'ManagedMatView') = 1" }, ComparisonMode.EXACT_COMMAND_STRING);
bsc.setCapabilitySupport(Capability.INSERT_WITH_QUERYEXPRESSION, true);
plan = (RelationalPlan) TestOptimizer.helpPlanCommand(command, metadata, new DefaultCapabilitiesFinder(bsc), analysis, new String[] { // $NON-NLS-1$
"INSERT INTO MatTable1 (e1) SELECT g_0.e1 FROM MatTable.MatTable AS g_0 WHERE mvstatus('MatView', 'ManagedMatView') = 1" }, ComparisonMode.EXACT_COMMAND_STRING);
Collection<Annotation> annotations = analysis.getAnnotations();
// $NON-NLS-1$
assertNotNull("Expected annotations but got none", annotations);
// $NON-NLS-1$
assertEquals("Expected catagory mat view", annotations.iterator().next().getCategory(), Annotation.MATERIALIZED_VIEW);
}
use of org.teiid.query.analysis.AnalysisRecord in project teiid by teiid.
the class TestMaterialization method testMaterializedTransformation.
@Test
public void testMaterializedTransformation() throws Exception {
// $NON-NLS-1$
String userSql = "SELECT MATVIEW.E1 FROM 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.e1 FROM MatTable.MatTable 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);
}
Aggregations