Search in sources :

Example 16 with ResultSetOptions

use of org.apache.drill.exec.physical.resultSet.impl.ResultSetLoaderImpl.ResultSetOptions in project drill by apache.

the class TestResultSetLoaderProjection method testScalarMapConflict.

@Test
public void testScalarMapConflict() {
    List<SchemaPath> selection = RowSetTestUtils.projectList("col.child");
    TupleMetadata schema = new SchemaBuilder().add("col", MinorType.VARCHAR).buildSchema();
    ResultSetOptions options = new ResultSetOptionBuilder().projection(Projections.parse(selection)).readerSchema(schema).build();
    try {
        new ResultSetLoaderImpl(fixture.allocator(), options);
        fail();
    } catch (UserException e) {
        assertTrue(e.getErrorType() == ErrorType.VALIDATION);
    }
}
Also used : SchemaPath(org.apache.drill.common.expression.SchemaPath) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) UserException(org.apache.drill.common.exceptions.UserException) ResultSetOptions(org.apache.drill.exec.physical.resultSet.impl.ResultSetLoaderImpl.ResultSetOptions) SubOperatorTest(org.apache.drill.test.SubOperatorTest) EvfTest(org.apache.drill.categories.EvfTest) Test(org.junit.Test)

Example 17 with ResultSetOptions

use of org.apache.drill.exec.physical.resultSet.impl.ResultSetLoaderImpl.ResultSetOptions in project drill by apache.

the class TestResultSetLoaderProjection method testArrayMapConflict.

@Test
public void testArrayMapConflict() {
    List<SchemaPath> selection = RowSetTestUtils.projectList("col.child");
    TupleMetadata schema = new SchemaBuilder().addArray("col", MinorType.VARCHAR).buildSchema();
    ResultSetOptions options = new ResultSetOptionBuilder().projection(Projections.parse(selection)).readerSchema(schema).build();
    try {
        new ResultSetLoaderImpl(fixture.allocator(), options);
        fail();
    } catch (UserException e) {
        assertTrue(e.getErrorType() == ErrorType.VALIDATION);
    }
}
Also used : SchemaPath(org.apache.drill.common.expression.SchemaPath) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) UserException(org.apache.drill.common.exceptions.UserException) ResultSetOptions(org.apache.drill.exec.physical.resultSet.impl.ResultSetLoaderImpl.ResultSetOptions) SubOperatorTest(org.apache.drill.test.SubOperatorTest) EvfTest(org.apache.drill.categories.EvfTest) Test(org.junit.Test)

Example 18 with ResultSetOptions

use of org.apache.drill.exec.physical.resultSet.impl.ResultSetLoaderImpl.ResultSetOptions in project drill by apache.

the class TestResultSetLoaderProjection method testProjectionDynamic.

@Test
public void testProjectionDynamic() {
    List<SchemaPath> selection = RowSetTestUtils.projectList("c", "b", "e");
    ResultSetOptions options = new ResultSetOptionBuilder().projection(Projections.parse(selection)).build();
    ResultSetLoader rsLoader = new ResultSetLoaderImpl(fixture.allocator(), options);
    RowSetLoader rootWriter = rsLoader.writer();
    rootWriter.addColumn(SchemaBuilder.columnSchema("a", MinorType.INT, DataMode.REQUIRED));
    rootWriter.addColumn(SchemaBuilder.columnSchema("b", MinorType.INT, DataMode.REQUIRED));
    rootWriter.addColumn(SchemaBuilder.columnSchema("c", MinorType.INT, DataMode.REQUIRED));
    rootWriter.addColumn(SchemaBuilder.columnSchema("d", MinorType.INT, DataMode.REQUIRED));
    doProjectionTest(rsLoader);
}
Also used : ResultSetLoader(org.apache.drill.exec.physical.resultSet.ResultSetLoader) SchemaPath(org.apache.drill.common.expression.SchemaPath) RowSetLoader(org.apache.drill.exec.physical.resultSet.RowSetLoader) ResultSetOptions(org.apache.drill.exec.physical.resultSet.impl.ResultSetLoaderImpl.ResultSetOptions) SubOperatorTest(org.apache.drill.test.SubOperatorTest) EvfTest(org.apache.drill.categories.EvfTest) Test(org.junit.Test)

Example 19 with ResultSetOptions

use of org.apache.drill.exec.physical.resultSet.impl.ResultSetLoaderImpl.ResultSetOptions in project drill by apache.

the class TestResultSetLoaderProjection method testProjectWithOverflow.

/**
 * Verify that the projection code plays nice with vector overflow. Overflow
 * is the most complex operation in this subsystem with many specialized
 * methods that must work together flawlessly. This test ensures that
 * non-projected columns stay in the background and don't interfere
 * with overflow logic.
 */
@Test
public void testProjectWithOverflow() {
    List<SchemaPath> selection = RowSetTestUtils.projectList("small", "dummy");
    TupleMetadata schema = new SchemaBuilder().add("big", MinorType.VARCHAR).add("small", MinorType.VARCHAR).buildSchema();
    ResultSetOptions options = new ResultSetOptionBuilder().rowCountLimit(ValueVector.MAX_ROW_COUNT).projection(Projections.parse(selection)).readerSchema(schema).build();
    ResultSetLoader rsLoader = new ResultSetLoaderImpl(fixture.allocator(), options);
    RowSetLoader rootWriter = rsLoader.writer();
    byte[] big = new byte[600];
    Arrays.fill(big, (byte) 'X');
    byte[] small = new byte[512];
    Arrays.fill(small, (byte) 'X');
    rsLoader.startBatch();
    int count = 0;
    while (!rootWriter.isFull()) {
        rootWriter.start();
        rootWriter.scalar(0).setBytes(big, big.length);
        rootWriter.scalar(1).setBytes(small, small.length);
        rootWriter.save();
        count++;
    }
    // Number of rows should be driven by size of the
    // projected vector ("small"), not by the larger, unprojected
    // "big" vector.
    // Our row count should include the overflow row
    int expectedCount = ValueVector.MAX_BUFFER_SIZE / small.length;
    assertEquals(expectedCount + 1, count);
    // Loader's row count should include only "visible" rows
    assertEquals(expectedCount, rootWriter.rowCount());
    // Total count should include invisible and look-ahead rows.
    assertEquals(expectedCount + 1, rsLoader.totalRowCount());
    // Result should exclude the overflow row
    RowSet result = fixture.wrap(rsLoader.harvest());
    assertEquals(expectedCount, result.rowCount());
    result.clear();
    // Next batch should start with the overflow row
    rsLoader.startBatch();
    assertEquals(1, rootWriter.rowCount());
    assertEquals(expectedCount + 1, rsLoader.totalRowCount());
    result = fixture.wrap(rsLoader.harvest());
    assertEquals(1, result.rowCount());
    result.clear();
    rsLoader.close();
}
Also used : ResultSetLoader(org.apache.drill.exec.physical.resultSet.ResultSetLoader) SchemaPath(org.apache.drill.common.expression.SchemaPath) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) SingleRowSet(org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) RowSetLoader(org.apache.drill.exec.physical.resultSet.RowSetLoader) ResultSetOptions(org.apache.drill.exec.physical.resultSet.impl.ResultSetLoaderImpl.ResultSetOptions) SubOperatorTest(org.apache.drill.test.SubOperatorTest) EvfTest(org.apache.drill.categories.EvfTest) Test(org.junit.Test)

Example 20 with ResultSetOptions

use of org.apache.drill.exec.physical.resultSet.impl.ResultSetLoaderImpl.ResultSetOptions in project drill by apache.

the class TestResultSetLoaderProjection method testScalarArrayConflict.

@Test
public void testScalarArrayConflict() {
    List<SchemaPath> selection = RowSetTestUtils.projectList("col[0]");
    TupleMetadata schema = new SchemaBuilder().add("col", MinorType.VARCHAR).buildSchema();
    ResultSetOptions options = new ResultSetOptionBuilder().projection(Projections.parse(selection)).readerSchema(schema).build();
    try {
        new ResultSetLoaderImpl(fixture.allocator(), options);
        fail();
    } catch (UserException e) {
        assertTrue(e.getErrorType() == ErrorType.VALIDATION);
    }
}
Also used : SchemaPath(org.apache.drill.common.expression.SchemaPath) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) UserException(org.apache.drill.common.exceptions.UserException) ResultSetOptions(org.apache.drill.exec.physical.resultSet.impl.ResultSetLoaderImpl.ResultSetOptions) SubOperatorTest(org.apache.drill.test.SubOperatorTest) EvfTest(org.apache.drill.categories.EvfTest) Test(org.junit.Test)

Aggregations

ResultSetOptions (org.apache.drill.exec.physical.resultSet.impl.ResultSetLoaderImpl.ResultSetOptions)38 SubOperatorTest (org.apache.drill.test.SubOperatorTest)37 Test (org.junit.Test)37 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)33 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)32 ResultSetLoader (org.apache.drill.exec.physical.resultSet.ResultSetLoader)29 RowSetLoader (org.apache.drill.exec.physical.resultSet.RowSetLoader)23 SchemaPath (org.apache.drill.common.expression.SchemaPath)22 EvfTest (org.apache.drill.categories.EvfTest)17 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)12 VectorContainer (org.apache.drill.exec.record.VectorContainer)10 UserException (org.apache.drill.common.exceptions.UserException)8 SingleRowSet (org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet)7 RowSetReader (org.apache.drill.exec.physical.rowSet.RowSetReader)6 ScalarWriter (org.apache.drill.exec.vector.accessor.ScalarWriter)5 ColumnMetadata (org.apache.drill.exec.record.metadata.ColumnMetadata)3 ArrayReader (org.apache.drill.exec.vector.accessor.ArrayReader)3 ScalarReader (org.apache.drill.exec.vector.accessor.ScalarReader)3 TupleWriter (org.apache.drill.exec.vector.accessor.TupleWriter)2 CustomErrorContext (org.apache.drill.common.exceptions.CustomErrorContext)1