Search in sources :

Example 26 with TransformationMetadata

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());
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) Procedure(org.teiid.metadata.Procedure) Properties(java.util.Properties) Test(org.junit.Test)

Example 27 with TransformationMetadata

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());
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 28 with TransformationMetadata

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);
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 29 with TransformationMetadata

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);
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) Table(org.teiid.metadata.Table) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) QueryNode(org.teiid.query.mapping.relational.QueryNode) Schema(org.teiid.metadata.Schema) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 30 with TransformationMetadata

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 });
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) CompositeMetadataStore(org.teiid.query.metadata.CompositeMetadataStore) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Aggregations

TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)427 Test (org.junit.Test)352 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)163 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)108 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)97 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)89 List (java.util.List)83 CommandContext (org.teiid.query.util.CommandContext)64 HardcodedDataManager (org.teiid.query.processor.HardcodedDataManager)63 ArrayList (java.util.ArrayList)56 TranslationUtility (org.teiid.cdk.api.TranslationUtility)35 MetadataFactory (org.teiid.metadata.MetadataFactory)35 FakeDataManager (org.teiid.query.processor.FakeDataManager)35 RealMetadataFactory (org.teiid.query.unittest.RealMetadataFactory)35 Schema (org.teiid.metadata.Schema)33 Table (org.teiid.metadata.Table)27 FunctionTree (org.teiid.query.function.FunctionTree)22 Column (org.teiid.metadata.Column)21 Command (org.teiid.language.Command)20 UDFSource (org.teiid.query.function.UDFSource)20