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