Search in sources :

Example 1 with AnalyticsMetaData

use of com.couchbase.client.java.analytics.AnalyticsMetaData in project couchbase-jvm-clients by couchbase.

the class AnalyticsCollectionIntegrationTest method performsDataverseQuery.

@Test
void performsDataverseQuery() {
    // default
    analytics.createDataset(dataset, bucket.name());
    analytics.createDataverse(dataverse);
    analytics.createDataset(dataset, bucket.name(), createDatasetAnalyticsOptions().dataverseName(dataverse));
    // REQUEST_PLUS makes query hang
    // AnalyticsOptions opts = AnalyticsOptions.analyticsOptions().scanConsistency(AnalyticsScanConsistency.REQUEST_PLUS).timeout(Duration.ofSeconds(300));
    AnalyticsResult result = cluster.analyticsQuery("SELECT * FROM " + dataverse + "." + dataset + " where " + dataset + ".test= \"hello\"");
    List<JsonObject> rows = result.rowsAs(JsonObject.class);
    assertFalse(!rows.isEmpty());
    AnalyticsMetaData meta = result.metaData();
    assertFalse(meta.clientContextId().isEmpty());
    assertTrue(meta.signature().isPresent());
    assertFalse(meta.requestId().isEmpty());
    assertEquals(AnalyticsStatus.SUCCESS, meta.status());
    assertFalse(meta.metrics().elapsedTime().isZero());
    assertFalse(meta.metrics().executionTime().isZero());
    assertEquals(rows.size(), meta.metrics().resultCount());
    // assertEquals(rows.size(), meta.metrics().processedObjects()); // fails
    // assertTrue(meta.metrics().resultSize() > 0); // fails
    assertTrue(meta.warnings().isEmpty());
// assertEquals(1, meta.metrics().errorCount()); //fails
}
Also used : JsonObject(com.couchbase.client.java.json.JsonObject) AnalyticsResult(com.couchbase.client.java.analytics.AnalyticsResult) AnalyticsMetaData(com.couchbase.client.java.analytics.AnalyticsMetaData) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 2 with AnalyticsMetaData

use of com.couchbase.client.java.analytics.AnalyticsMetaData in project couchbase-jvm-clients by couchbase.

the class AnalyticsIntegrationTest method performsDataverseQuery.

@Test
void performsDataverseQuery() {
    AnalyticsResult result = cluster.analyticsQuery("SELECT DataverseName FROM Metadata.`Dataverse`");
    List<JsonObject> rows = result.rowsAs(JsonObject.class);
    assertFalse(rows.isEmpty());
    for (JsonObject row : rows) {
        assertNotNull(row.get("DataverseName"));
    }
    AnalyticsMetaData meta = result.metaData();
    assertFalse(meta.clientContextId().isEmpty());
    assertTrue(meta.signature().isPresent());
    assertFalse(meta.requestId().isEmpty());
    assertEquals(AnalyticsStatus.SUCCESS, meta.status());
    assertFalse(meta.metrics().elapsedTime().isZero());
    assertFalse(meta.metrics().executionTime().isZero());
    assertEquals(rows.size(), meta.metrics().resultCount());
    assertEquals(rows.size(), meta.metrics().processedObjects());
    assertTrue(meta.metrics().resultSize() > 0);
    assertTrue(meta.warnings().isEmpty());
    assertEquals(0, meta.metrics().errorCount());
}
Also used : JsonObject(com.couchbase.client.java.json.JsonObject) AnalyticsResult(com.couchbase.client.java.analytics.AnalyticsResult) AnalyticsMetaData(com.couchbase.client.java.analytics.AnalyticsMetaData) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

AnalyticsMetaData (com.couchbase.client.java.analytics.AnalyticsMetaData)2 AnalyticsResult (com.couchbase.client.java.analytics.AnalyticsResult)2 JsonObject (com.couchbase.client.java.json.JsonObject)2 JavaIntegrationTest (com.couchbase.client.java.util.JavaIntegrationTest)2 Test (org.junit.jupiter.api.Test)2