Search in sources :

Example 6 with QueryMetadataInterface

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);
}
Also used : RequestMessage(org.teiid.client.RequestMessage) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Example 7 with QueryMetadataInterface

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);
}
Also used : Command(org.teiid.query.sql.lang.Command) BatchedUpdateCommand(org.teiid.query.sql.lang.BatchedUpdateCommand) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) BatchedUpdateCommand(org.teiid.query.sql.lang.BatchedUpdateCommand) AtomicRequestMessage(org.teiid.dqp.message.AtomicRequestMessage) Test(org.junit.Test)

Example 8 with QueryMetadataInterface

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);
}
Also used : CacheDirective(org.teiid.translator.CacheDirective) Command(org.teiid.query.sql.lang.Command) BatchedUpdateCommand(org.teiid.query.sql.lang.BatchedUpdateCommand) TupleSource(org.teiid.common.buffer.TupleSource) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) RegisterRequestParameter(org.teiid.query.processor.RegisterRequestParameter) Test(org.junit.Test)

Example 9 with QueryMetadataInterface

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);
}
Also used : QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) MetadataResult(org.teiid.client.metadata.MetadataResult) Test(org.junit.Test)

Example 10 with QueryMetadataInterface

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));
}
Also used : QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) MetadataResult(org.teiid.client.metadata.MetadataResult) Test(org.junit.Test)

Aggregations

QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)507 Test (org.junit.Test)464 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)210 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)189 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)177 List (java.util.List)126 Command (org.teiid.query.sql.lang.Command)90 ArrayList (java.util.ArrayList)72 FakeDataManager (org.teiid.query.processor.FakeDataManager)48 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)43 BigInteger (java.math.BigInteger)41 CommandContext (org.teiid.query.util.CommandContext)37 HardcodedDataManager (org.teiid.query.processor.HardcodedDataManager)29 AnalysisRecord (org.teiid.query.analysis.AnalysisRecord)16 MetadataStore (org.teiid.metadata.MetadataStore)12 Schema (org.teiid.metadata.Schema)11 BatchedUpdateCommand (org.teiid.query.sql.lang.BatchedUpdateCommand)11 TeiidException (org.teiid.core.TeiidException)10 TeiidProcessingException (org.teiid.core.TeiidProcessingException)10 CapabilitiesFinder (org.teiid.query.optimizer.capabilities.CapabilitiesFinder)10