Search in sources :

Example 16 with SingleRowSet

use of org.apache.drill.test.rowSet.RowSet.SingleRowSet in project drill by axbaretto.

the class TestBatchValidator method testRepeatedBadArrayOffset.

@Test
public void testRepeatedBadArrayOffset() {
    BatchSchema schema = new SchemaBuilder().add("a", MinorType.VARCHAR, DataMode.REPEATED).build();
    SingleRowSet batch = fixture.rowSetBuilder(schema).addRow((Object) strArray()).addRow((Object) strArray("fred", "barney", "wilma")).addRow((Object) strArray("dino")).build();
    VectorAccessible va = batch.vectorAccessible();
    ValueVector v = va.iterator().next().getValueVector();
    RepeatedVarCharVector vc = (RepeatedVarCharVector) v;
    UInt4Vector ov = vc.getOffsetVector();
    ov.getMutator().set(3, 1);
    BatchValidator validator = new BatchValidator(batch.vectorAccessible(), true);
    validator.validate();
    List<String> errors = validator.errors();
    assertEquals(1, errors.size());
    assertTrue(errors.get(0).contains("Decreasing offsets"));
    batch.clear();
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) SingleRowSet(org.apache.drill.test.rowSet.RowSet.SingleRowSet) VectorAccessible(org.apache.drill.exec.record.VectorAccessible) RepeatedVarCharVector(org.apache.drill.exec.vector.RepeatedVarCharVector) BatchSchema(org.apache.drill.exec.record.BatchSchema) SchemaBuilder(org.apache.drill.test.rowSet.schema.SchemaBuilder) UInt4Vector(org.apache.drill.exec.vector.UInt4Vector) Test(org.junit.Test)

Example 17 with SingleRowSet

use of org.apache.drill.test.rowSet.RowSet.SingleRowSet in project drill by axbaretto.

the class TestCopier method testMultipleOutputDesc.

// Also verifies that SV2s work
@Test
public void testMultipleOutputDesc() throws Exception {
    BatchSchema schema = SortTestUtilities.nonNullSchema();
    CopierTester tester = new CopierTester(fixture);
    tester.sortOrder = Ordering.ORDER_DESC;
    tester.nullOrder = Ordering.NULLS_UNSPECIFIED;
    SingleRowSet input = makeDataSet(schema, 0, 2, 10).toIndirect();
    RowSetUtilities.reverse(input.getSv2());
    tester.addInput(input);
    input = makeDataSet(schema, 1, 2, 10).toIndirect();
    RowSetUtilities.reverse(input.getSv2());
    tester.addInput(input);
    tester.addOutput(makeDataSet(schema, 19, -1, 10));
    tester.addOutput(makeDataSet(schema, 9, -1, 10));
    tester.run();
}
Also used : SingleRowSet(org.apache.drill.test.rowSet.RowSet.SingleRowSet) BatchSchema(org.apache.drill.exec.record.BatchSchema) CopierTester(org.apache.drill.exec.physical.impl.xsort.managed.SortTestUtilities.CopierTester) OperatorTest(org.apache.drill.categories.OperatorTest) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 18 with SingleRowSet

use of org.apache.drill.test.rowSet.RowSet.SingleRowSet in project drill by axbaretto.

the class TestSorter method testMapKey.

@Test
@Ignore("DRILL-5384")
public void testMapKey() throws Exception {
    BatchSchema schema = new SchemaBuilder().addMap("map").add("key", MinorType.INT).add("value", MinorType.VARCHAR).resumeSchema().build();
    SingleRowSet input = fixture.rowSetBuilder(schema).addRow(3, "third").addRow(1, "first").addRow(2, "second").withSv2().build();
    SingleRowSet output = fixture.rowSetBuilder(schema).addRow(1, "first").addRow(2, "second").addRow(3, "third").build();
    Sort popConfig = makeSortConfig("map.key", Ordering.ORDER_ASC, Ordering.NULLS_LAST);
    runSorterTest(popConfig, input, output);
}
Also used : SingleRowSet(org.apache.drill.test.rowSet.RowSet.SingleRowSet) BatchSchema(org.apache.drill.exec.record.BatchSchema) SchemaBuilder(org.apache.drill.test.rowSet.schema.SchemaBuilder) Sort(org.apache.drill.exec.physical.config.Sort) Ignore(org.junit.Ignore) DrillTest(org.apache.drill.test.DrillTest) OperatorTest(org.apache.drill.categories.OperatorTest) Test(org.junit.Test)

Example 19 with SingleRowSet

use of org.apache.drill.test.rowSet.RowSet.SingleRowSet in project drill by axbaretto.

the class TestSorter method testTwoRows.

// Paranoia: sort with two rows.
@Test
public void testTwoRows() throws Exception {
    BatchSchema schema = SortTestUtilities.nonNullSchema();
    SingleRowSet rowSet = new RowSetBuilder(fixture.allocator(), schema).addRow(1, "1").addRow(0, "0").withSv2().build();
    SingleRowSet expected = new RowSetBuilder(fixture.allocator(), schema).addRow(0, "0").addRow(1, "1").build();
    runSorterTest(rowSet, expected);
}
Also used : RowSetBuilder(org.apache.drill.test.rowSet.RowSetBuilder) SingleRowSet(org.apache.drill.test.rowSet.RowSet.SingleRowSet) BatchSchema(org.apache.drill.exec.record.BatchSchema) DrillTest(org.apache.drill.test.DrillTest) OperatorTest(org.apache.drill.categories.OperatorTest) Test(org.junit.Test)

Example 20 with SingleRowSet

use of org.apache.drill.test.rowSet.RowSet.SingleRowSet in project drill by axbaretto.

the class TestSorter method testSingleRow.

// Sanity test: single row
@Test
public void testSingleRow() throws Exception {
    BatchSchema schema = SortTestUtilities.nonNullSchema();
    SingleRowSet rowSet = new RowSetBuilder(fixture.allocator(), schema).addRow(0, "0").withSv2().build();
    SingleRowSet expected = new RowSetBuilder(fixture.allocator(), schema).addRow(0, "0").build();
    runSorterTest(rowSet, expected);
}
Also used : RowSetBuilder(org.apache.drill.test.rowSet.RowSetBuilder) SingleRowSet(org.apache.drill.test.rowSet.RowSet.SingleRowSet) BatchSchema(org.apache.drill.exec.record.BatchSchema) DrillTest(org.apache.drill.test.DrillTest) OperatorTest(org.apache.drill.categories.OperatorTest) Test(org.junit.Test)

Aggregations

SingleRowSet (org.apache.drill.test.rowSet.RowSet.SingleRowSet)93 SchemaBuilder (org.apache.drill.test.rowSet.schema.SchemaBuilder)78 Test (org.junit.Test)74 BatchSchema (org.apache.drill.exec.record.BatchSchema)64 SubOperatorTest (org.apache.drill.test.SubOperatorTest)57 RowSetReader (org.apache.drill.test.rowSet.RowSetReader)38 RowSet (org.apache.drill.test.rowSet.RowSet)27 ScalarReader (org.apache.drill.exec.vector.accessor.ScalarReader)25 RowSetComparison (org.apache.drill.test.rowSet.RowSetComparison)25 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)22 RowSetLoader (org.apache.drill.exec.physical.rowSet.RowSetLoader)17 ResultSetLoader (org.apache.drill.exec.physical.rowSet.ResultSetLoader)16 ValueVector (org.apache.drill.exec.vector.ValueVector)13 ScalarElementReader (org.apache.drill.exec.vector.accessor.ScalarElementReader)13 RowSetBuilder (org.apache.drill.test.rowSet.RowSetBuilder)13 ColumnSize (org.apache.drill.exec.record.RecordBatchSizer.ColumnSize)10 UInt4Vector (org.apache.drill.exec.vector.UInt4Vector)10 TupleWriter (org.apache.drill.exec.vector.accessor.TupleWriter)10 ScalarWriter (org.apache.drill.exec.vector.accessor.ScalarWriter)9 RepeatedValueVector (org.apache.drill.exec.vector.complex.RepeatedValueVector)9