use of org.apache.drill.test.ClientFixture in project drill by apache.
the class TestAliasSubstitution method testStorageUserAliasFallbackToPublic.
@Test
public void testStorageUserAliasFallbackToPublic() throws Exception {
try {
ClientFixture client = cluster.clientBuilder().property(DrillProperties.USER, TEST_USER_2).property(DrillProperties.PASSWORD, TEST_USER_2_PASSWORD).build();
storageAliasesRegistry.createUserAliases(TEST_USER_2);
storageAliasesRegistry.getUserAliases(TEST_USER_2).put("`foobar`", "`cp`", false);
storageAliasesRegistry.createPublicAliases();
storageAliasesRegistry.getPublicAliases().put("`foobar1`", "`cp`", false);
String sql = "SELECT * FROM foobar1.`tpch/lineitem.parquet` limit 1";
long recordCount = client.queryBuilder().sql(sql).run().recordCount();
assertEquals(1, recordCount);
} finally {
storageAliasesRegistry.deleteUserAliases(TEST_USER_2);
storageAliasesRegistry.deletePublicAliases();
}
}
use of org.apache.drill.test.ClientFixture in project drill by apache.
the class TestAliasSystemTables method testStorageAliasesTable.
@Test
public void testStorageAliasesTable() throws Exception {
try {
ClientFixture client = cluster.clientBuilder().property(DrillProperties.USER, TEST_USER_2).property(DrillProperties.PASSWORD, TEST_USER_2_PASSWORD).build();
storageAliasesRegistry.createPublicAliases();
storageAliasesRegistry.getPublicAliases().put("`foobar`", "`cp`", false);
storageAliasesRegistry.getPublicAliases().put("`abc`", "`def`", false);
storageAliasesRegistry.createUserAliases(TEST_USER_1);
storageAliasesRegistry.getUserAliases(TEST_USER_1).put("`ghi`", "`jkl`", false);
storageAliasesRegistry.createUserAliases(TEST_USER_2);
storageAliasesRegistry.getUserAliases(TEST_USER_2).put("`mno`", "`pqr`", false);
String sql = "SELECT * FROM sys.storage_aliases";
client.testBuilder().sqlQuery(sql).unOrdered().baselineColumns("alias", "name", "user", "isPublic").baselineValues("`foobar`", "`cp`", null, true).baselineValues("`abc`", "`def`", null, true).baselineValues("`ghi`", "`jkl`", TEST_USER_1, false).baselineValues("`mno`", "`pqr`", TEST_USER_2, false).go();
} finally {
storageAliasesRegistry.deletePublicAliases();
storageAliasesRegistry.deleteUserAliases(TEST_USER_1);
storageAliasesRegistry.deleteUserAliases(TEST_USER_2);
}
}
use of org.apache.drill.test.ClientFixture in project drill by apache.
the class TestMemoryCalculator method getPlanForQuery.
private String getPlanForQuery(String query, long outputBatchSize, long slice_target) throws Exception {
ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).setOptionDefault(ExecConstants.OUTPUT_BATCH_SIZE, outputBatchSize).setOptionDefault(ExecConstants.SLICE_TARGET, slice_target);
String plan;
try (ClusterFixture cluster = builder.build();
ClientFixture client = cluster.clientFixture()) {
plan = client.queryBuilder().sql(query).explainJson();
}
return plan;
}
use of org.apache.drill.test.ClientFixture in project drill by apache.
the class TestMemoryCalculator method TestZKBasedQueue.
@Test
public void TestZKBasedQueue() throws Exception {
String sql = "select * from cp.`employee.json`";
ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).configProperty(EmbeddedQueryQueue.ENABLED, true);
try (ClusterFixture cluster = builder.build();
ClientFixture client = cluster.clientFixture()) {
client.queryBuilder().sql(sql).run();
}
}
use of org.apache.drill.test.ClientFixture in project drill by apache.
the class TestMapAccessors method testDrill6809.
/**
* Test that the schema inference handles repeated map vectors.
* <p>
* It turns out that when some operators create a map array, it adds the
* $offset$ vector to the list of children for the map's MaterializedField.
* But, the RowSet utilities do not. This test verifies that both forms
* work.
*/
@Test
public void testDrill6809() throws Exception {
try (ClusterFixture cluster = ClusterFixture.standardCluster(dirTestWatcher);
ClientFixture client = cluster.clientFixture()) {
// Input: {"a" : [ {"c": 1} ], "b" : 2.1}
String sql = "select * from `cp`.`jsoninput/repeatedmap_sort_bug.json`";
RowSet actual = client.queryBuilder().sql(sql).rowSet();
TupleMetadata schema = new SchemaBuilder().addMapArray("a").addNullable("c", MinorType.BIGINT).resumeSchema().addNullable("b", MinorType.FLOAT8).buildSchema();
RowSet expected = fixture.rowSetBuilder(schema).addRow(mapArray(mapValue(1L)), 2.1D).build();
RowSetUtilities.verify(expected, actual);
}
}
Aggregations