use of org.apache.drill.test.ClientFixture in project drill by apache.
the class TestOrderedMuxExchange method testLimitOnOrderedMux.
/**
* Test case to verify the OrderedMuxExchange created for order by with limit.
* It checks that the limit is pushed down the OrderedMuxExchange.
*
* @throws Exception if anything goes wrong
*/
@Test
public void testLimitOnOrderedMux() throws Exception {
ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).maxParallelization(1).configProperty(ExecConstants.SYS_STORE_PROVIDER_LOCAL_ENABLE_WRITE, true);
try (ClusterFixture cluster = builder.build();
ClientFixture client = cluster.clientFixture()) {
client.alterSession(ExecConstants.SLICE_TARGET, 10);
String sql = "SELECT emp_id, emp_name FROM dfs.`empTable` e order BY emp_name, emp_id limit 10";
client.testBuilder().unOrdered().optionSettingQueriesForTestQuery("alter session set `planner.slice_target` = 10;").sqlQuery(sql).optionSettingQueriesForBaseline(// Use default option setting.
"alter session set `planner.enable_ordered_mux_exchange` = false").sqlBaselineQuery(sql).build().run();
client.alterSession(ExecConstants.ORDERED_MUX_EXCHANGE, true);
String explainText = client.queryBuilder().sql(sql).explainText();
assertTrue(explainText.matches(String.format(MATCH_PATTERN_ACROSS_LINES + "%s" + MATCH_PATTERN_ACROSS_LINES + "%s" + MATCH_PATTERN_ACROSS_LINES, ORDERED_MUX_EXCHANGE, TOPN)));
}
}
use of org.apache.drill.test.ClientFixture in project drill by apache.
the class DrillSeparatePlanningTest method getResultsHelper.
private int getResultsHelper(final QueryPlanFragments planFragments) throws Exception {
int totalRows = 0;
for (PlanFragment fragment : planFragments.getFragmentsList()) {
DrillbitEndpoint assignedNode = fragment.getAssignment();
ClientFixture fragmentClient = cluster.client(assignedNode.getAddress(), assignedNode.getUserPort());
RowSet rowSet = fragmentClient.queryBuilder().sql("select hostname, user_port from sys.drillbits where `current`=true").rowSet();
assertEquals(1, rowSet.rowCount());
RowSetReader reader = rowSet.reader();
assertTrue(reader.next());
String host = reader.scalar("hostname").getString();
int port = reader.scalar("user_port").getInt();
rowSet.clear();
assertEquals(assignedNode.getAddress(), host);
assertEquals(assignedNode.getUserPort(), port);
List<PlanFragment> fragmentList = Lists.newArrayList();
fragmentList.add(fragment);
QuerySummary summary = fragmentClient.queryBuilder().plan(fragmentList).run();
totalRows += summary.recordCount();
fragmentClient.close();
}
return totalRows;
}
use of org.apache.drill.test.ClientFixture in project drill by apache.
the class TestAliasCommands method setUpBeforeClass.
@BeforeClass
public static void setUpBeforeClass() throws Exception {
cluster = ClusterFixture.bareBuilder(dirTestWatcher).configProperty(ExecConstants.USER_AUTHENTICATION_ENABLED, true).configProperty(ExecConstants.IMPERSONATION_ENABLED, true).configProperty(ExecConstants.USER_AUTHENTICATOR_IMPL, UserAuthenticatorTestImpl.TYPE).configProperty(DrillProperties.USER, PROCESS_USER).configProperty(DrillProperties.PASSWORD, PROCESS_USER_PASSWORD).build();
ClientFixture admin = cluster.clientBuilder().property(DrillProperties.USER, PROCESS_USER).property(DrillProperties.PASSWORD, PROCESS_USER_PASSWORD).build();
admin.alterSystem(ExecConstants.ADMIN_USERS_KEY, ADMIN_USER + "," + PROCESS_USER);
admin.alterSystem(ExecConstants.ADMIN_USER_GROUPS_KEY, ADMIN_GROUP);
client = cluster.clientBuilder().property(DrillProperties.USER, ADMIN_USER).property(DrillProperties.PASSWORD, ADMIN_USER_PASSWORD).build();
storageAliasesRegistry = cluster.drillbit().getContext().getAliasRegistryProvider().getStorageAliasesRegistry();
tableAliasesRegistry = cluster.drillbit().getContext().getAliasRegistryProvider().getTableAliasesRegistry();
}
use of org.apache.drill.test.ClientFixture in project drill by apache.
the class TestAliasCommands method testCreateTableAliasAsTheSameUser.
@Test
public void testCreateTableAliasAsTheSameUser() throws Exception {
try {
ClientFixture client = cluster.clientBuilder().property(DrillProperties.USER, TEST_USER_2).property(DrillProperties.PASSWORD, TEST_USER_2_PASSWORD).build();
String sql = "CREATE ALIAS tpch_lineitem for table cp.`tpch/lineitem.parquet` AS USER '%s'";
client.testBuilder().sqlQuery(sql, TEST_USER_2).unOrdered().baselineColumns("ok", "summary").baselineValues(true, "Table alias '`tpch_lineitem`' for '`cp`.`default`.`tpch/lineitem.parquet`' created successfully").go();
List<String> expectedAliases = Collections.singletonList("`tpch_lineitem`");
List<String> expectedValues = Collections.singletonList("`cp`.`default`.`tpch/lineitem.parquet`");
List<String> actualAliases = new ArrayList<>();
List<String> actualValues = new ArrayList<>();
tableAliasesRegistry.getUserAliases(TEST_USER_2).getAllAliases().forEachRemaining(entry -> {
actualAliases.add(entry.getKey());
actualValues.add(entry.getValue());
});
assertEquals(expectedAliases, actualAliases);
assertEquals(expectedValues, actualValues);
} finally {
tableAliasesRegistry.deleteUserAliases(TEST_USER_2);
}
}
use of org.apache.drill.test.ClientFixture in project drill by apache.
the class TestAliasCommands method testNonAdminCreateTableAliasAsAnotherUser.
@Test
public void testNonAdminCreateTableAliasAsAnotherUser() throws Exception {
try {
ClientFixture client = cluster.clientBuilder().property(DrillProperties.USER, TEST_USER_2).property(DrillProperties.PASSWORD, TEST_USER_2_PASSWORD).build();
String sql = "CREATE ALIAS tpch_lineitem for table cp.`tpch/lineitem.parquet` AS USER '%s'";
client.queryBuilder().sql(sql, TEST_USER_1).run();
fail();
} catch (UserRemoteException e) {
MatcherAssert.assertThat(e.getVerboseMessage(), containsString("PERMISSION ERROR: Not authorized to perform operations on aliases for other users."));
} finally {
storageAliasesRegistry.deleteUserAliases(TEST_USER_1);
}
}
Aggregations