use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestRequest method testProcessRequest.
/**
* Test Request.processRequest().
* Test processing the same query twice, and make sure that doesn't cause problems.
* See defect 17209.
* @throws Exception
* @since 4.2
*/
@Test
public void testProcessRequest() throws Exception {
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
// Try before plan is cached.
// If this doesn't throw an exception, assume it was successful.
RequestMessage message = new RequestMessage(QUERY);
DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(metadata, RealMetadataFactory.example1VDB());
helpProcessMessage(message, null, workContext);
// Try again, now that plan is already cached.
// If this doesn't throw an exception, assume it was successful.
message = new RequestMessage(QUERY);
helpProcessMessage(message, null, workContext);
}
use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestDataTierManager method testCheckForUpdatesWithBatched.
@Test
public void testCheckForUpdatesWithBatched() throws Exception {
helpSetupDataTierManager();
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
AtomicRequestMessage request = helpSetupRequest("delete from bqt1.smalla", 1, metadata);
Command command = helpGetCommand("insert into bqt1.smalla (stringkey) values ('1')", metadata);
BatchedUpdateCommand bac = new BatchedUpdateCommand(Arrays.asList(request.getCommand(), command));
request.setCommand(bac);
DataTierTupleSource dtts = new DataTierTupleSource(request, workItem, connectorManager.registerRequest(request), dtm, limit);
pullTuples(dtts, 2);
}
use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestDataTierManager method testCaching.
@Test
public void testCaching() throws Exception {
assertEquals(0, connectorManager.getExecuteCount().get());
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
CacheDirective cd = new CacheDirective();
this.connectorManager.cacheDirective = cd;
helpSetupDataTierManager();
Command command = helpSetupRequest("SELECT stringkey from bqt1.smalla", 1, metadata).getCommand();
RegisterRequestParameter rrp = new RegisterRequestParameter();
rrp.connectorBindingId = "x";
TupleSource ts = dtm.registerRequest(context, command, "foo", rrp);
assertTrue(ts instanceof CachingTupleSource);
assertEquals(10, pullTuples(ts, -1));
assertEquals(1, connectorManager.getExecuteCount().get());
assertFalse(rrp.doNotCache);
assertFalse(((CachingTupleSource) ts).dtts.errored);
assertNull(((CachingTupleSource) ts).dtts.scope);
ts.closeSource();
assertEquals(1, this.rm.getRsCache().getCachePutCount());
assertEquals(1, this.rm.getRsCache().getTotalCacheEntries());
// same session, should be cached
command = helpSetupRequest("SELECT stringkey from bqt1.smalla", 1, metadata).getCommand();
rrp = new RegisterRequestParameter();
rrp.connectorBindingId = "x";
ts = dtm.registerRequest(context, command, "foo", rrp);
assertFalse(ts instanceof CachingTupleSource);
assertEquals(10, pullTuples(ts, -1));
assertEquals(1, connectorManager.getExecuteCount().get());
assertTrue(rrp.doNotCache);
// switch sessions
command = helpSetupRequest("SELECT stringkey from bqt1.smalla", 1, metadata).getCommand();
this.context.getSession().setSessionId("different");
rrp = new RegisterRequestParameter();
rrp.connectorBindingId = "x";
ts = dtm.registerRequest(context, command, "foo", rrp);
assertTrue(ts instanceof CachingTupleSource);
assertEquals(9, pullTuples(ts, 9));
assertEquals(2, connectorManager.getExecuteCount().get());
assertFalse(rrp.doNotCache);
// should force read all
ts.closeSource();
assertFalse(((CachingTupleSource) ts).dtts.errored);
assertNull(((CachingTupleSource) ts).dtts.scope);
assertEquals(2, this.rm.getRsCache().getCachePutCount());
assertEquals(2, this.rm.getRsCache().getTotalCacheEntries());
// proactive invalidation, removes immediately
command = helpSetupRequest("SELECT stringkey from bqt1.smalla", 1, metadata).getCommand();
cd.setInvalidation(Invalidation.IMMEDIATE);
rrp = new RegisterRequestParameter();
rrp.connectorBindingId = "x";
ts = dtm.registerRequest(context, command, "foo", rrp);
assertTrue(ts instanceof CachingTupleSource);
assertEquals(10, pullTuples(ts, -1));
assertEquals(3, connectorManager.getExecuteCount().get());
assertFalse(rrp.doNotCache);
}
use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestMetaDataProcessor method testDefect16629_moneyType.
@Test
public void testDefect16629_moneyType() throws Exception {
QueryMetadataInterface metadata = TestMetaDataProcessor.examplePrivatePhysicalModel();
// $NON-NLS-1$
String sql = "SELECT e1 FROM pm1.g2";
MetadataResult response = helpTestQuery(metadata, sql, TestMetaDataProcessor.examplePrivatePhysicalModelVDB());
helpCheckNumericAttributes(response, 0, 21, 19, 4);
}
use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestMetaDataProcessor method testArrayAgg.
@Test
public void testArrayAgg() throws Exception {
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
// $NON-NLS-1$
String sql = "SELECT array_agg(e1) FROM pm1.g2";
MetadataResult response = helpTestQuery(metadata, sql, RealMetadataFactory.example1VDB());
assertEquals("string[]", response.getColumnMetadata()[0].get(ResultsMetadataConstants.DATA_TYPE));
}
Aggregations