Search in sources :

Example 1 with JsonStringArrayList

use of org.apache.drill.exec.util.JsonStringArrayList in project drill by apache.

the class TestDirectoryExplorerUDFs method testConstExprFolding_maxDir0.

@Test
public void testConstExprFolding_maxDir0() throws Exception {
    test("use dfs.root");
    List<String> allFiles = ImmutableList.<String>builder().add("smallfile").add("SMALLFILE_2").add("bigfile").add("BIGFILE_2").build();
    String query = "select * from dfs.`" + path + "/*/*.csv` where dir0 = %s('dfs.root','" + path + "')";
    for (ConstantFoldingTestConfig config : tests) {
        // make all of the other folders unexpected patterns, except for the one expected in this case
        List<String> excludedPatterns = Lists.newArrayList();
        excludedPatterns.addAll(allFiles);
        excludedPatterns.remove(config.expectedFolderName);
        // The list is easier to construct programmatically, but the API below takes an array to make it easier
        // to write a list as a literal array in a typical test definition
        String[] excludedArray = new String[excludedPatterns.size()];
        testPlanMatchingPatterns(String.format(query, config.funcName), new String[] { config.expectedFolderName }, excludedPatterns.toArray(excludedArray));
    }
    JsonStringArrayList<Text> list = new JsonStringArrayList<>();
    list.add(new Text("1"));
    list.add(new Text("2"));
    list.add(new Text("3"));
    testBuilder().sqlQuery(String.format(query, tests.get(0).funcName)).unOrdered().baselineColumns("columns", "dir0").baselineValues(list, tests.get(0).expectedFolderName).go();
}
Also used : JsonStringArrayList(org.apache.drill.exec.util.JsonStringArrayList) Text(org.apache.drill.exec.util.Text) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Aggregations

JsonStringArrayList (org.apache.drill.exec.util.JsonStringArrayList)1 Text (org.apache.drill.exec.util.Text)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Test (org.junit.Test)1