Drill includes several data sets for testing, and also provides some tools for generating test data sets.
There are three primary data sets bundled with drill for testing:
See seventhTest() in ExampleTest for an example of how to do this.
When using the BaseDirTestWatcher you can make sample-data accessible from the dfs
storage plugin by doing the following:
public class TestMyClass { @ClassRule public static final BaseDirTestWatcher dirTestWatcher = new BaseDirTestWatcher(); @BeforeClass public static void setupFiles() { dirTestWatcher.copyFileToRoot(Paths.get("sample-data", "region.parquet")); } @Test public void simpleTest() { // dfs.root.`sample-data/region.parquet` will be accessible from my test } }
Or if you are extending BaseTestQuery
public class TestMyClass extends BaseTestQuery { @BeforeClass public static void setupFiles() { dirTestWatcher.copyFileToRoot(Paths.get("sample-data", "region.parquet")); } @Test public void simpleTest() { // dfs.root.`sample-data/region.parquet` will be accessible from my test } }
See sixthTest() in ExampleTest for an example of how to do this.
When using the BaseDirTestWatcher you can make data from exec/java-exec/src/test/resources accessible from the dfs
storage plugin by doing the following:
public class TestMyClass { @ClassRule public static final BaseDirTestWatcher dirTestWatcher = new BaseDirTestWatcher(); @BeforeClass public static void setupFiles() { dirTestWatcher.copyResourceToRoot(Paths.get("join", "empty_part")); } @Test public void simpleTest() { // src/test/resources/join/empty_part is acessible at dfs.root.`join/empty_part` from my test } }
Or if you are extending BaseTestQuery
public class TestMyClass extends BaseTestQuery { @BeforeClass public static void setupFiles() { dirTestWatcher.copyResourceToRoot(Paths.get("join", "empty_part")); } @Test public void simpleTest() { // src/test/resources/join/empty_part is acessible at dfs.root.`join/empty_part` from my test } }
TPCH data is accessible via the classpath storage plugin
cp.`tpch/customer.parquet`
There are a few ways to generate data for testing:
The JsonFileBuilder can be used to create json data files. It's useful for creating data files for both integration and unit tests. An example of using the JsonFileBuilder can be found in secondTest() in ExampleTest.
The MockScanner is a special scanner that generates data for a query. It can only be used for integration testing.
The MockScanner can be used directly from sql queries. An example can be found in thirdTest() in ExampleTest.
The example uses the following query
SELECT id_i, name_s10 FROM `mock`.`employees_5`
The select columns encode the name and type of the columns to generate. The table name also encodes the number of records to generate.