Search in sources :

Example 61 with Schema

use of org.teiid.metadata.Schema in project teiid by teiid.

the class TestCapabilitiesUtil method testSupportRowOffset.

@Test
public void testSupportRowOffset() throws Exception {
    // Set up metadata
    TransformationMetadata metadata = RealMetadataFactory.example1Cached();
    Schema modelID = metadata.getMetadataStore().getSchema("PM1");
    // Set up capabilities
    FakeCapabilitiesFinder finder = getFinder(Capability.ROW_OFFSET, false);
    // Test capabilities util
    assertEquals(false, CapabilitiesUtil.supportsRowOffset(modelID, metadata, finder));
    finder = getFinder(Capability.ROW_OFFSET, true);
    // Test capabilities util
    assertEquals(true, CapabilitiesUtil.supportsRowOffset(modelID, metadata, finder));
}
Also used : FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) Schema(org.teiid.metadata.Schema) Test(org.junit.Test)

Example 62 with Schema

use of org.teiid.metadata.Schema in project teiid by teiid.

the class TestCapabilitiesUtil method helpTestSupportsScalar.

public void helpTestSupportsScalar(SourceCapabilities caps, Function function, boolean expectedValue) throws QueryMetadataException, TeiidComponentException, QueryResolverException {
    // Set up metadata
    TransformationMetadata metadata = RealMetadataFactory.example1Cached();
    Schema modelID = metadata.getMetadataStore().getSchema("PM1");
    // Set up capabilities
    FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
    // $NON-NLS-1$
    finder.addCapabilities("pm1", caps);
    ResolverVisitor.resolveLanguageObject(function, metadata);
    // Test capabilities util
    boolean actual = CapabilitiesUtil.supportsScalarFunction(modelID, function, metadata, finder);
    // $NON-NLS-1$
    assertEquals("Got wrong answer for supports", expectedValue, actual);
}
Also used : FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) Schema(org.teiid.metadata.Schema)

Example 63 with Schema

use of org.teiid.metadata.Schema in project teiid by teiid.

the class TestCapabilitiesUtil method helpTtestSupportsCaseExpression.

public void helpTtestSupportsCaseExpression(boolean supports, boolean searched) throws QueryMetadataException, TeiidComponentException {
    // Set up metadata
    TransformationMetadata metadata = RealMetadataFactory.example1Cached();
    Schema modelID = metadata.getMetadataStore().getSchema("PM1");
    // Set up capabilities
    FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities sourceCaps = new BasicSourceCapabilities();
    if (searched) {
        sourceCaps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, supports);
    } else {
        sourceCaps.setCapabilitySupport(Capability.QUERY_CASE, supports);
    }
    // $NON-NLS-1$
    finder.addCapabilities("pm1", sourceCaps);
    // Test capabilities util
    boolean actual = false;
    if (searched) {
        actual = CapabilitiesUtil.supportsSearchedCaseExpression(modelID, metadata, finder);
    } else {
        actual = CapabilitiesUtil.supportsCaseExpression(modelID, metadata, finder);
    }
    // $NON-NLS-1$
    assertEquals("Got wrong answer for supports", supports, actual);
}
Also used : FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) Schema(org.teiid.metadata.Schema)

Example 64 with Schema

use of org.teiid.metadata.Schema in project teiid by teiid.

the class TestCapabilitiesUtil method testSupportsOrderBy2.

@Test
public void testSupportsOrderBy2() throws Exception {
    // Set up metadata
    TransformationMetadata metadata = RealMetadataFactory.example1Cached();
    Schema modelID = metadata.getMetadataStore().getSchema("PM1");
    // Set up capabilities
    FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities sourceCaps = new BasicSourceCapabilities();
    sourceCaps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
    // $NON-NLS-1$
    finder.addCapabilities("pm1", sourceCaps);
    // Test capabilities util
    boolean actual = CapabilitiesUtil.supportsOrderBy(modelID, metadata, finder);
    // $NON-NLS-1$
    assertEquals("Got wrong answer for supports", false, actual);
}
Also used : FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) Schema(org.teiid.metadata.Schema) Test(org.junit.Test)

Example 65 with Schema

use of org.teiid.metadata.Schema in project teiid by teiid.

the class TestLimit method exampleMetadata.

private static TransformationMetadata exampleMetadata() {
    MetadataStore metadataStore = new MetadataStore();
    // Create models
    // $NON-NLS-1$
    Schema pm1 = RealMetadataFactory.createPhysicalModel("pm1", metadataStore);
    // $NON-NLS-1$
    Schema vm1 = RealMetadataFactory.createVirtualModel("vm1", metadataStore);
    // Create physical groups
    // $NON-NLS-1$
    Table pm1g1 = RealMetadataFactory.createPhysicalGroup("g1", pm1);
    // $NON-NLS-1$
    Table pm1g2 = RealMetadataFactory.createPhysicalGroup("g2", pm1);
    // $NON-NLS-1$
    Table pm1g3 = RealMetadataFactory.createPhysicalGroup("g3", pm1);
    // $NON-NLS-1$
    Table pm1g4 = RealMetadataFactory.createPhysicalGroup("g4", pm1);
    // $NON-NLS-1$
    Table pm1g5 = RealMetadataFactory.createPhysicalGroup("g5", pm1);
    // $NON-NLS-1$
    Table pm1g6 = RealMetadataFactory.createPhysicalGroup("g6", pm1);
    // Create physical elements
    RealMetadataFactory.createElements(pm1g1, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
    RealMetadataFactory.createElements(pm1g2, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
    RealMetadataFactory.createElements(pm1g3, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
    List<Column> pm1g4e = RealMetadataFactory.createElements(pm1g4, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
    pm1g4e.get(1).setSelectable(false);
    pm1g4e.get(3).setSelectable(false);
    List<Column> pm1g5e = RealMetadataFactory.createElements(pm1g5, // $NON-NLS-1$
    new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING });
    pm1g5e.get(0).setSelectable(false);
    RealMetadataFactory.createElements(pm1g6, // $NON-NLS-1$ //$NON-NLS-2$
    new String[] { "in", "in3" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
    // Create virtual groups
    // $NON-NLS-1$ //$NON-NLS-2$
    QueryNode vm1g1n1 = new QueryNode("SELECT * FROM pm1.g1 LIMIT 100");
    // $NON-NLS-1$
    Table vm1g1 = RealMetadataFactory.createVirtualGroup("g1", vm1, vm1g1n1);
    // Create virtual elements
    RealMetadataFactory.createElements(vm1g1, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
    // $NON-NLS-1$ //$NON-NLS-2$
    QueryNode vm1g2n1 = new QueryNode("SELECT * FROM vm1.g1 ORDER BY e1");
    // $NON-NLS-1$
    Table vm1g2 = RealMetadataFactory.createVirtualGroup("g2", vm1, vm1g2n1);
    // Create virtual elements
    RealMetadataFactory.createElements(vm1g2, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
    return RealMetadataFactory.createTransformationMetadata(metadataStore, "example");
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) Table(org.teiid.metadata.Table) Column(org.teiid.metadata.Column) QueryNode(org.teiid.query.mapping.relational.QueryNode) Schema(org.teiid.metadata.Schema)

Aggregations

Schema (org.teiid.metadata.Schema)92 MetadataStore (org.teiid.metadata.MetadataStore)47 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)37 Table (org.teiid.metadata.Table)35 Test (org.junit.Test)34 QueryNode (org.teiid.query.mapping.relational.QueryNode)20 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)19 Column (org.teiid.metadata.Column)18 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)18 Procedure (org.teiid.metadata.Procedure)16 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)11 List (java.util.List)10 ArrayList (java.util.ArrayList)9 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)8 ProcedureParameter (org.teiid.metadata.ProcedureParameter)8 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)7 FunctionMethod (org.teiid.metadata.FunctionMethod)6 TempMetadataStore (org.teiid.query.metadata.TempMetadataStore)6 CompositeMetadataStore (org.teiid.query.metadata.CompositeMetadataStore)5 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)5