Search in sources :

Example 1 with QueryBuilder

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

the class TestParquetLimitPushDown method testMultipleFiles.

@Test
public void testMultipleFiles() throws Exception {
    String query = "select * from dfs.`parquet/users` limit 1";
    QueryBuilder.QuerySummary summary = queryBuilder().sql(query).run();
    assertTrue(summary.succeeded());
    assertEquals(1, summary.recordCount());
    String plan = queryBuilder().sql(query).explainText();
    assertThat(plan, containsString("numRowGroups=1"));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) QueryBuilder(org.apache.drill.test.QueryBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 2 with QueryBuilder

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

the class TestParquetLimitPushDown method testLimitZero.

@Test
public void testLimitZero() throws Exception {
    String query = "select * from dfs.`parquet/users` limit 0";
    QueryBuilder.QuerySummary summary = queryBuilder().sql(query).run();
    assertTrue(summary.succeeded());
    assertEquals(0, summary.recordCount());
    String plan = queryBuilder().sql(query).explainText();
    assertThat(plan, containsString("numRowGroups=1"));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) QueryBuilder(org.apache.drill.test.QueryBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 3 with QueryBuilder

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

the class TestParquetLimitPushDown method testMultipleRowGroups.

@Test
public void testMultipleRowGroups() throws Exception {
    String query = "select * from dfs.`parquet/multirowgroup.parquet` limit 1";
    QueryBuilder.QuerySummary summary = queryBuilder().sql(query).run();
    assertTrue(summary.succeeded());
    assertEquals(1, summary.recordCount());
    String plan = queryBuilder().sql(query).explainText();
    assertThat(plan, containsString("numRowGroups=1"));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) QueryBuilder(org.apache.drill.test.QueryBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 4 with QueryBuilder

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

the class TestSequenceFileReader method testLimitPushdown.

@Test
public void testLimitPushdown() throws Exception {
    String sql = "select * from cp.`sequencefiles/simple.seq` limit 1 offset 1";
    QueryBuilder builder = client.queryBuilder().sql(sql);
    RowSet sets = builder.rowSet();
    assertEquals(1, sets.rowCount());
    sets.clear();
}
Also used : RowSet(org.apache.drill.exec.physical.rowSet.RowSet) QueryBuilder(org.apache.drill.test.QueryBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 5 with QueryBuilder

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

the class TestSequenceFileReader method testExplicitQuery.

@Test
public void testExplicitQuery() throws Exception {
    String sql = "select convert_from(binary_key, 'UTF8') as binary_key from cp.`sequencefiles/simple.seq`";
    QueryBuilder builder = client.queryBuilder().sql(sql);
    RowSet sets = builder.rowSet();
    TupleMetadata schema = new SchemaBuilder().addNullable(SequenceFileBatchReader.KEY_SCHEMA, MinorType.VARCHAR).build();
    RowSet expected = new RowSetBuilder(client.allocator(), schema).addRow(byteWritableString("key0")).addRow(byteWritableString("key1")).build();
    assertEquals(2, sets.rowCount());
    new RowSetComparison(expected).verifyAndClearAll(sets);
}
Also used : RowSetBuilder(org.apache.drill.exec.physical.rowSet.RowSetBuilder) RowSetComparison(org.apache.drill.test.rowSet.RowSetComparison) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) QueryBuilder(org.apache.drill.test.QueryBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Aggregations

QueryBuilder (org.apache.drill.test.QueryBuilder)65 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)61 Test (org.junit.Test)53 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)48 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)48 RowSetComparison (org.apache.drill.test.rowSet.RowSetComparison)48 RowSetBuilder (org.apache.drill.exec.physical.rowSet.RowSetBuilder)45 ClusterTest (org.apache.drill.test.ClusterTest)39 SlowTest (org.apache.drill.categories.SlowTest)14 SqlFunctionTest (org.apache.drill.categories.SqlFunctionTest)3 UnlikelyTest (org.apache.drill.categories.UnlikelyTest)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 Ignore (org.junit.Ignore)2 EvfTest (org.apache.drill.categories.EvfTest)1 SqlTest (org.apache.drill.categories.SqlTest)1 BaseCsvTest (org.apache.drill.exec.store.easy.text.compliant.BaseCsvTest)1 Disabled (org.junit.jupiter.api.Disabled)1 Test (org.junit.jupiter.api.Test)1