Search in sources :

Example 1 with ImmutableMap

use of org.apache.drill.shaded.guava.com.google.common.collect.ImmutableMap in project drill by apache.

the class TestDirectoryExplorerUDFs method testDirectoryUDFsWithAndWithoutMetadataCache.

// DRILL-4720
@Test
public void testDirectoryUDFsWithAndWithoutMetadataCache() throws Exception {
    // prepare test table with partitions
    Path tableRelPath = Paths.get("table_with_partitions");
    File tableDir = dirTestWatcher.makeRootSubDir(tableRelPath);
    File dataFile = dirTestWatcher.getRootDir().toPath().resolve(Paths.get("parquet", "alltypes_required.parquet")).toFile();
    createPartitions(tableDir.toPath(), dataFile, 2);
    Map<String, String> configurations = ImmutableMap.<String, String>builder().put("mindir", "part_1").put("imindir", "part_1").put("maxdir", "part_2").put("imaxdir", "part_2").build();
    String query = "select dir0 from dfs.`%s` where dir0 = %s('dfs', '%s') limit 1";
    // run tests without metadata cache
    for (Map.Entry<String, String> entry : configurations.entrySet()) {
        testBuilder().sqlQuery(query, tableRelPath, entry.getKey(), tableRelPath).unOrdered().baselineColumns("dir0").baselineValues(entry.getValue()).go();
    }
    // generate metadata
    test("refresh table metadata dfs.`%s`", tableRelPath);
    // run tests with metadata cache
    for (Map.Entry<String, String> entry : configurations.entrySet()) {
        testBuilder().sqlQuery(query, tableRelPath, entry.getKey(), tableRelPath).unOrdered().baselineColumns("dir0").baselineValues(entry.getValue()).go();
    }
}
Also used : Path(java.nio.file.Path) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) File(java.io.File) ImmutableMap(org.apache.drill.shaded.guava.com.google.common.collect.ImmutableMap) Map(java.util.Map) Test(org.junit.Test) PlannerTest(org.apache.drill.categories.PlannerTest) SqlTest(org.apache.drill.categories.SqlTest)

Aggregations

File (java.io.File)1 Path (java.nio.file.Path)1 Map (java.util.Map)1 PlannerTest (org.apache.drill.categories.PlannerTest)1 SqlTest (org.apache.drill.categories.SqlTest)1 ImmutableMap (org.apache.drill.shaded.guava.com.google.common.collect.ImmutableMap)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Test (org.junit.Test)1