Search in sources :

Example 76 with TestBuilder

use of org.apache.drill.test.TestBuilder in project drill by apache.

the class AvroFormatTest method testMapSchema.

@Test
public void testMapSchema() throws Exception {
    String sql = "select map_field from dfs.`%s`";
    TestBuilder testBuilder = testBuilder().sqlQuery(sql, mapTableName).unOrdered().baselineColumns("map_field");
    for (long i = 0; i < AvroDataGenerator.RECORD_COUNT; i++) {
        testBuilder.baselineValues(mapOfObject("key1", i, "key2", i + 1));
    }
    testBuilder.go();
}
Also used : TestBuilder(org.apache.drill.test.TestBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 77 with TestBuilder

use of org.apache.drill.test.TestBuilder in project drill by apache.

the class AvroFormatTest method testDecimal.

@Test
public void testDecimal() throws Exception {
    int numRows = 5;
    String fileName = dataGenerator.generateDecimalData(numRows);
    TestBuilder testBuilder = testBuilder().sqlQuery("select * from dfs.`%s`", fileName).unOrdered().baselineColumns("col_dec_pos_bytes", "col_dec_neg_bytes", "col_dec_pos_fixed", "col_dec_neg_fixed");
    for (int i = 0; i < numRows; i++) {
        testBuilder.baselineValues(new BigDecimal(BigInteger.valueOf(100 + i), 2), new BigDecimal(BigInteger.valueOf(-200 + i), 2), new BigDecimal(BigInteger.valueOf(300 + i), 2), new BigDecimal(BigInteger.valueOf(-400 + i), 2));
    }
    testBuilder.go();
}
Also used : TestBuilder(org.apache.drill.test.TestBuilder) BigDecimal(java.math.BigDecimal) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 78 with TestBuilder

use of org.apache.drill.test.TestBuilder in project drill by apache.

the class TestCsvHeader method testEmptyFinalColumn.

@Test
public void testEmptyFinalColumn() throws Exception {
    File table_dir = dirTestWatcher.makeTestTmpSubDir(Paths.get("emptyFinalColumn"));
    BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(new File(table_dir, "a.csvh")));
    os.write("field1,field2\n".getBytes());
    for (int i = 0; i < 10000; i++) {
        os.write("a,\n".getBytes());
    }
    os.flush();
    os.close();
    String query = "select * from dfs.tmp.emptyFinalColumn";
    TestBuilder builder = testBuilder().sqlQuery(query).ordered().baselineColumns("field1", "field2");
    for (int i = 0; i < 10000; i++) {
        builder.baselineValues("a", "");
    }
    builder.go();
}
Also used : FileOutputStream(java.io.FileOutputStream) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream) TestBuilder(org.apache.drill.test.TestBuilder) EvfTest(org.apache.drill.categories.EvfTest) Test(org.junit.Test)

Example 79 with TestBuilder

use of org.apache.drill.test.TestBuilder in project drill by apache.

the class TestSelectWithOption method testWithResult.

private void testWithResult(String query, Object... expectedResult) throws Exception {
    TestBuilder builder = testBuilder().sqlQuery(query).ordered().baselineColumns("columns");
    for (Object o : expectedResult) {
        builder = builder.baselineValues(o);
    }
    builder.build().run();
}
Also used : TestBuilder(org.apache.drill.test.TestBuilder)

Example 80 with TestBuilder

use of org.apache.drill.test.TestBuilder in project drill by apache.

the class TopNBatchTest method sortOneKeyAscending.

/**
 * End to end test of the TopN operator.
 * @throws Throwable
 */
@Test
public void sortOneKeyAscending() throws Throwable {
    ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher);
    try (ClusterFixture cluster = builder.build();
        ClientFixture client = cluster.clientFixture()) {
        TestBuilder testBuilder = new TestBuilder(new ClusterFixture.FixtureTestServices(client));
        testBuilder.ordered().physicalPlanFromFile("topN/one_key_sort.json").baselineColumns("blue").go();
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) ClientFixture(org.apache.drill.test.ClientFixture) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) TestBuilder(org.apache.drill.test.TestBuilder) OperatorTest(org.apache.drill.categories.OperatorTest) Test(org.junit.Test)

Aggregations

TestBuilder (org.apache.drill.test.TestBuilder)94 Test (org.junit.Test)74 File (java.io.File)27 OperatorTest (org.apache.drill.categories.OperatorTest)27 ClusterTest (org.apache.drill.test.ClusterTest)20 BufferedWriter (java.io.BufferedWriter)18 FileWriter (java.io.FileWriter)18 UnlikelyTest (org.apache.drill.categories.UnlikelyTest)16 ParquetTest (org.apache.drill.categories.ParquetTest)10 TestBuilder.mapOfObject (org.apache.drill.test.TestBuilder.mapOfObject)6 Path (java.nio.file.Path)5 JsonFileBuilder (org.apache.drill.test.rowSet.file.JsonFileBuilder)5 Category (org.junit.experimental.categories.Category)5 SlowTest (org.apache.drill.categories.SlowTest)4 SqlTest (org.apache.drill.categories.SqlTest)4 JsonStringHashMap (org.apache.drill.exec.util.JsonStringHashMap)4 IOException (java.io.IOException)3 UserRemoteException (org.apache.drill.common.exceptions.UserRemoteException)3 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)3 RowSetBuilder (org.apache.drill.exec.physical.rowSet.RowSetBuilder)3