use of org.apache.drill.test.ClientFixture in project drill by apache.
the class TestSimpleExternalSort method sortOneKeyDescendingMergeSort.
@Test
public void sortOneKeyDescendingMergeSort() throws Throwable {
ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher);
try (ClusterFixture cluster = builder.build();
ClientFixture client = cluster.clientFixture()) {
List<QueryDataBatch> results = client.queryBuilder().physicalResource("xsort/one_key_sort_descending.json").results();
assertEquals(1_000_000, client.countResults(results));
validateResults(client.allocator(), results);
}
}
use of org.apache.drill.test.ClientFixture in project drill by apache.
the class TestSimpleExternalSort method outOfMemoryExternalSort.
@Test
public void outOfMemoryExternalSort() throws Throwable {
ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).configProperty("drill.memory.fragment.max", 50_000_000).configProperty("drill.memory.fragment.initial", 2_000_000).configProperty("drill.memory.operator.max", 30_000_000).configProperty("drill.memory.operator.initial", 2_000_000);
try (ClusterFixture cluster = builder.build();
ClientFixture client = cluster.clientFixture()) {
List<QueryDataBatch> results = client.queryBuilder().physicalResource("/xsort/oom_sort_test.json").results();
assertEquals(10_000_000, client.countResults(results));
long previousBigInt = Long.MAX_VALUE;
for (QueryDataBatch b : results) {
RecordBatchLoader loader = new RecordBatchLoader(client.allocator());
if (b.getHeader().getRowCount() > 0) {
loader.load(b.getHeader().getDef(), b.getData());
BigIntVector c1 = (BigIntVector) loader.getValueAccessorById(BigIntVector.class, loader.getValueVectorId(new SchemaPath("blue", ExpressionPosition.UNKNOWN)).getFieldIds()).getValueVector();
BigIntVector.Accessor a1 = c1.getAccessor();
for (int i = 0; i < c1.getAccessor().getValueCount(); i++) {
assertTrue(String.format("%d < %d", previousBigInt, a1.get(i)), previousBigInt >= a1.get(i));
previousBigInt = a1.get(i);
}
assertTrue(String.format("%d == %d", a1.get(0), a1.get(a1.getValueCount() - 1)), a1.get(0) != a1.get(a1.getValueCount() - 1));
}
loader.clear();
b.release();
}
}
}
use of org.apache.drill.test.ClientFixture in project drill by apache.
the class TestInfoSchemaFilterPushDown method testLazySchemaRegistration.
/**
* As reported in DRILL-8057, even queries against INFORMATION_SCHEMA that
* included a filter that could be pushed down would be penalised by eager
* schema registration executed on every enabled storage plugin instance.
* This resulted in slow or even failed INFORMATION_SCHEMA schema queries
* when some storage plugin was unresponsive, even if it was not needed for
* the query being run. This test checks that lazy schema registration is
* working by installing a mock storage plugin to act as a canary.
*/
@Test
public void testLazySchemaRegistration() throws Exception {
ClusterMockStorageFixture cluster = ClusterFixture.builder(dirTestWatcher).buildCustomMockStorage();
// This mock storage plugin throws an exception from registerSchemas which
// would have been enough to correctly make this test fail were it not that
// the exception gets swallowed by StoragePluginRegistryImpl so we need to
// inspect a counter instead.
cluster.insertMockStorage("registerSchema canary", true);
ClientFixture client = cluster.clientFixture();
final String query = "SELECT * FROM INFORMATION_SCHEMA.`TABLES` WHERE TABLE_SCHEMA='INFORMATION_SCHEMA'";
client.queryBuilder().sql(query).run();
StoragePluginRegistry spr = cluster.drillbit().getContext().getStorage();
MockBreakageStorage mbs = (MockBreakageStorage) spr.getPlugin("registerSchema canary");
// no attempt to register schemas on the canary should have been made
assertEquals(0, mbs.registerAttemptCount);
}
use of org.apache.drill.test.ClientFixture in project drill by apache.
the class TestOpenTSDBPlugin method testInformationSchemaWrongPluginConfig.
@Test
public void testInformationSchemaWrongPluginConfig() throws Exception {
try (ClusterFixture cluster = ClusterFixture.bareBuilder(dirTestWatcher).build();
ClientFixture client = cluster.clientFixture()) {
int portNumber = QueryTestUtil.getFreePortNumber(10_000, 200);
final StoragePluginRegistry pluginRegistry = cluster.drillbit().getContext().getStorage();
OpenTSDBStoragePluginConfig storagePluginConfig = new OpenTSDBStoragePluginConfig(String.format("http://localhost:%s/", portNumber));
storagePluginConfig.setEnabled(true);
pluginRegistry.put(OpenTSDBStoragePluginConfig.NAME, storagePluginConfig);
String query = "select * from information_schema.`views`";
client.queryBuilder().sql(query).run();
}
}
use of org.apache.drill.test.ClientFixture in project drill by apache.
the class TestSemiJoin method testInClauseWithSemiJoinDisabled.
@Test
public void testInClauseWithSemiJoinDisabled() throws Exception {
String sql = "select employee_id, full_name from cp.`employee.json` where employee_id in (select employee_id from cp.`employee.json` )";
ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).setOptionDefault(PlannerSettings.SEMIJOIN.getOptionName(), false);
try (ClusterFixture cluster = builder.build();
ClientFixture client = cluster.clientFixture()) {
String queryPlan = client.queryBuilder().sql(sql).explainText();
assertTrue(!queryPlan.contains("semi-join: =[true]"));
}
}
Aggregations