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