use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestODataMetadataProcessor method testSchema.
@Test
public void testSchema() throws Exception {
translator = new ODataExecutionFactory();
translator.start();
MetadataFactory mf = tripPinMetadata();
TransformationMetadata metadata = getTransformationMetadata(mf, this.translator);
String ddl = DDLStringVisitor.getDDLString(mf.getSchema(), null, null);
// System.out.println(ddl);
MetadataFactory mf2 = new MetadataFactory("vdb", 1, "northwind", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null);
QueryParser.getQueryParser().parseDDL(mf2, ddl);
Procedure p = mf.getSchema().getProcedure("ResetDataSource");
assertNotNull(p);
assertEquals(0, p.getParameters().size());
}
use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestOptimizer method testManyJoinsGreedy.
@Test
public void testManyJoinsGreedy() throws Exception {
TransformationMetadata tm = example1();
RealMetadataFactory.setCardinality("pm1.g5", 1000000, tm);
RealMetadataFactory.setCardinality("pm1.g4", 1000000, tm);
RealMetadataFactory.setCardinality("pm1.g1", 10000000, tm);
RealMetadataFactory.setCardinality("pm1.g8", 100, tm);
RealMetadataFactory.setCardinality("pm1.g3", 10000, tm);
RealMetadataFactory.setCardinality("pm1.g6", 100000, tm);
ProcessorPlan plan = helpPlan("SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2, pm1.g3, pm1.g4, pm1.g5, pm1.g6, pm1.g7, pm1.g8 " + // $NON-NLS-1$
"WHERE pm1.g1.e1 = pm1.g2.e1 AND pm1.g2.e1 = pm1.g3.e1 AND pm1.g3.e1 = pm1.g4.e1 AND pm1.g4.e1 = pm1.g5.e1 AND pm1.g5.e1=pm1.g6.e1 AND pm1.g6.e1=pm1.g7.e1 AND pm1.g7.e1=pm1.g8.e1", tm, new String[] { // $NON-NLS-1$
"SELECT pm1.g1.e1 FROM pm1.g1", // $NON-NLS-1$
"SELECT pm1.g2.e1 FROM pm1.g2", // $NON-NLS-1$
"SELECT pm1.g3.e1 FROM pm1.g3", // $NON-NLS-1$
"SELECT pm1.g4.e1 FROM pm1.g4", // $NON-NLS-1$
"SELECT pm1.g5.e1 FROM pm1.g5", // $NON-NLS-1$
"SELECT pm1.g6.e1 FROM pm1.g6", // $NON-NLS-1$
"SELECT pm1.g7.e1 FROM pm1.g7", // $NON-NLS-1$
"SELECT pm1.g8.e1 FROM pm1.g8" }, new DefaultCapabilitiesFinder(), // $NON-NLS-1$
ComparisonMode.CORRECTED_COMMAND_STRING);
RelationalPlan rp = (RelationalPlan) plan;
// g1 should be last
assertEquals("[pm1.g1.e1]", ((JoinNode) rp.getRootNode().getChildren()[0]).getRightExpressions().toString());
}
use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestOptimizer method testUnaliased.
@Test
public void testUnaliased() throws Exception {
// $NON-NLS-1$
String sql = "SELECT x.count + 1 FROM agg x";
TransformationMetadata metadata = RealMetadataFactory.fromDDL("create foreign table smalla (intkey integer); create view agg (count integer) as select intkey from smalla order by intkey limit 1", "x", "y");
BasicSourceCapabilities bsc = TestAggregatePushdown.getAggregateCapabilities();
bsc.setFunctionSupport("+", true);
TestOptimizer.helpPlan(sql, metadata, new String[] { "SELECT (v_0.c_0 + 1) FROM (SELECT g_0.intkey AS c_0 FROM y.smalla AS g_0 ORDER BY c_0 LIMIT 1) AS v_0" }, new DefaultCapabilitiesFinder(bsc), ComparisonMode.EXACT_COMMAND_STRING);
}
use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestOptimizer method testUnnamedAggInView.
@Test
public void testUnnamedAggInView() throws Exception {
MetadataStore metadataStore = new MetadataStore();
// $NON-NLS-1$
Schema bqt1 = RealMetadataFactory.createPhysicalModel("BQT1", metadataStore);
// $NON-NLS-1$
Schema vqt = RealMetadataFactory.createVirtualModel("VQT", metadataStore);
// $NON-NLS-1$
Table bqt1SmallA = RealMetadataFactory.createPhysicalGroup("SmallA", bqt1);
RealMetadataFactory.createElement("col", bqt1SmallA, DataTypeManager.DefaultDataTypes.STRING);
Table agg3 = RealMetadataFactory.createVirtualGroup("Agg3", vqt, new QueryNode("select count(*) from smalla"));
RealMetadataFactory.createElement("count", agg3, DataTypeManager.DefaultDataTypes.INTEGER);
TransformationMetadata metadata = RealMetadataFactory.createTransformationMetadata(metadataStore, "x");
BasicSourceCapabilities bac = getTypicalCapabilities();
bac.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
bac.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
bac.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
helpPlan("select count(*) from agg3", metadata, new String[] {}, new DefaultCapabilitiesFinder(bac), ComparisonMode.EXACT_COMMAND_STRING);
}
use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestDependentJoins method testSystemDependent.
@Test
public void testSystemDependent() throws TeiidComponentException, TeiidProcessingException {
// Create query
// $NON-NLS-1$
String sql = "SELECT pm1.g1.e1 FROM pm1.g1, sys.columns makedep where pm1.g1.e1 = sys.columns.name";
CompositeMetadataStore cms = new CompositeMetadataStore(Arrays.asList(RealMetadataFactory.example1Store(), SystemMetadata.getInstance().getSystemStore()));
TransformationMetadata tm = new TransformationMetadata(null, cms, null, null, null);
BasicSourceCapabilities bsc = new BasicSourceCapabilities();
bsc.setCapabilitySupport(Capability.CRITERIA_IN, true);
ProcessorPlan plan = TestOptimizer.helpPlan(// $NON-NLS-1$
sql, tm, null, new DefaultCapabilitiesFinder(bsc), new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT SYS.Columns.Name FROM SYS.Columns WHERE SYS.Columns.Name IN (<dependent values>)" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, new int[] { // Access
1, // DependentAccess
1, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
0, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
1, // Null
0, // PlanExecution
0, // Project - we expect a project over the system query
2, // Select
0, // Sort
0, // UnionAll
0 });
}
Aggregations