Search in sources :

Example 56 with ClientFixture

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();
    }
}
Also used : ClientFixture(org.apache.drill.test.ClientFixture) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 57 with ClientFixture

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);
    }
}
Also used : ClientFixture(org.apache.drill.test.ClientFixture) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 58 with ClientFixture

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;
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) ClientFixture(org.apache.drill.test.ClientFixture) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder)

Example 59 with ClientFixture

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();
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) ClientFixture(org.apache.drill.test.ClientFixture) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) Test(org.junit.Test)

Example 60 with ClientFixture

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);
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) ClientFixture(org.apache.drill.test.ClientFixture) SingleRowSet(org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Aggregations

ClientFixture (org.apache.drill.test.ClientFixture)122 Test (org.junit.Test)102 ClusterFixture (org.apache.drill.test.ClusterFixture)99 ClusterFixtureBuilder (org.apache.drill.test.ClusterFixtureBuilder)89 SlowTest (org.apache.drill.categories.SlowTest)46 OptionsTest (org.apache.drill.categories.OptionsTest)36 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)28 BaseTest (org.apache.drill.test.BaseTest)20 ClusterTest (org.apache.drill.test.ClusterTest)16 QueryDataBatch (org.apache.drill.exec.rpc.user.QueryDataBatch)12 DrillTest (org.apache.drill.test.DrillTest)10 OperatorTest (org.apache.drill.categories.OperatorTest)8 UserRemoteException (org.apache.drill.common.exceptions.UserRemoteException)7 RestClientFixture (org.apache.drill.test.RestClientFixture)4 ArrayList (java.util.ArrayList)3 SchemaPath (org.apache.drill.common.expression.SchemaPath)3 RecordBatchLoader (org.apache.drill.exec.record.RecordBatchLoader)3 BigIntVector (org.apache.drill.exec.vector.BigIntVector)3 File (java.io.File)2 PlanFragment (org.apache.drill.exec.proto.BitControl.PlanFragment)2