use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.
the class SecuredPhoenixDataTypeTest method doTestDataType.
private void doTestDataType() throws Exception {
String sql = "select * from phoenix123.v1.datatype";
QueryBuilder builder = queryBuilder().sql(sql);
RowSet sets = builder.rowSet();
TupleMetadata schema = new SchemaBuilder().addNullable("T_UUID", MinorType.VARCHAR).addNullable("T_VARCHAR", MinorType.VARCHAR).addNullable("T_CHAR", MinorType.VARCHAR).addNullable("T_BIGINT", MinorType.BIGINT).addNullable("T_INTEGER", MinorType.INT).addNullable("T_SMALLINT", MinorType.INT).addNullable("T_TINYINT", MinorType.INT).addNullable("T_DOUBLE", MinorType.FLOAT8).addNullable("T_FLOAT", MinorType.FLOAT4).addNullable("T_DECIMAL", MinorType.VARDECIMAL).addNullable("T_DATE", MinorType.DATE).addNullable("T_TIME", MinorType.TIME).addNullable("T_TIMESTAMP", MinorType.TIMESTAMP).addNullable("T_BINARY", MinorType.VARBINARY).addNullable("T_VARBINARY", MinorType.VARBINARY).addNullable("T_BOOLEAN", MinorType.BIT).build();
RowSet expected = new RowSetBuilder(client.allocator(), schema).addRow(U_U_I_D, "apache", "drill", Long.MAX_VALUE, Integer.MAX_VALUE, Short.MAX_VALUE, Byte.MAX_VALUE, Double.MAX_VALUE, Float.MAX_VALUE, BigDecimal.valueOf(10.11), LocalDate.parse("2021-12-12"), LocalTime.parse("12:12:12"), Instant.ofEpochMilli(1639311132000l), "a_b_c_d_e_".getBytes(), "12345".getBytes(), Boolean.TRUE).build();
new RowSetComparison(expected).verifyAndClearAll(sets);
}
use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.
the class SecuredPhoenixDataTypeTest method doTestArrayType.
private void doTestArrayType() throws Exception {
String sql = "select * from phoenix123.v1.arraytype";
QueryBuilder builder = queryBuilder().sql(sql);
RowSet sets = builder.rowSet();
TupleMetadata schema = new SchemaBuilder().addNullable("T_UUID", MinorType.VARCHAR).addArray("T_VARCHAR", MinorType.VARCHAR).addArray("T_CHAR", MinorType.VARCHAR).addArray("T_BIGINT", MinorType.BIGINT).addArray("T_INTEGER", MinorType.INT).addArray("T_DOUBLE", MinorType.FLOAT8).addArray("T_SMALLINT", MinorType.SMALLINT).addArray("T_TINYINT", MinorType.TINYINT).addArray("T_BOOLEAN", MinorType.BIT).build();
RowSet expected = new RowSetBuilder(client.allocator(), schema).addRow(U_U_I_D, strArray("apache", "drill", "1.20"), strArray("a", "b", "c"), longArray(Long.MIN_VALUE, Long.MAX_VALUE), intArray(Integer.MIN_VALUE, Integer.MAX_VALUE), doubleArray(Double.MIN_VALUE, Double.MAX_VALUE), shortArray(Short.MIN_VALUE, Short.MAX_VALUE), byteArray((int) Byte.MIN_VALUE, (int) Byte.MAX_VALUE), boolArray(Boolean.TRUE, Boolean.FALSE)).build();
new RowSetComparison(expected).verifyAndClearAll(sets);
}
use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.
the class TestLateralJoinCorrectnessBatchProcessing method testLeftAndRightWithLastMissingRows_MultipleBatch.
@Test
public void testLeftAndRightWithLastMissingRows_MultipleBatch() throws Exception {
leftContainer.add(nonEmptyLeftRowSet.container());
// Get the left IterOutcomes for Lateral Join
leftOutcomes.add(RecordBatch.IterOutcome.OK_NEW_SCHEMA);
// Create Left MockRecordBatch
final CloseableRecordBatch leftMockBatch = new MockRecordBatch(fixture.getFragmentContext(), operatorContext, leftContainer, leftOutcomes, leftContainer.get(0).getSchema());
// Get the right container with dummy data
final RowSet.SingleRowSet nonEmptyRightRowSet2 = fixture.rowSetBuilder(rightSchema).addRow(1, 11, 110, "item11").addRow(2, 22, 220, "item22").build();
final RowSet.SingleRowSet nonEmptyRightRowSet3 = fixture.rowSetBuilder(rightSchema).addRow(3, 33, 330, "item33_1").addRow(3, 33, 330, "item33_2").build();
final RowSet.SingleRowSet expectedRowSet = fixture.rowSetBuilder(expectedSchema).addRow(1, 10, "item1", 11, 110, "item11").addRow(2, 20, "item2", 22, 220, "item22").addRow(3, 30, "item3", 33, 330, "item33_1").addRow(3, 30, "item3", 33, 330, "item33_2").build();
rightContainer.add(emptyRightRowSet.container());
rightContainer.add(nonEmptyRightRowSet2.container());
rightContainer.add(nonEmptyRightRowSet3.container());
rightOutcomes.add(RecordBatch.IterOutcome.OK_NEW_SCHEMA);
rightOutcomes.add(RecordBatch.IterOutcome.OK);
rightOutcomes.add(RecordBatch.IterOutcome.EMIT);
final CloseableRecordBatch rightMockBatch = new MockRecordBatch(fixture.getFragmentContext(), operatorContext, rightContainer, rightOutcomes, rightContainer.get(0).getSchema());
final LateralJoinBatch ljBatch = new LateralJoinBatch(ljPopConfig, fixture.getFragmentContext(), leftMockBatch, rightMockBatch);
try {
assertTrue(RecordBatch.IterOutcome.OK_NEW_SCHEMA == ljBatch.next());
assertTrue(RecordBatch.IterOutcome.OK == ljBatch.next());
assertTrue(ljBatch.getRecordCount() == (nonEmptyRightRowSet2.rowCount() + nonEmptyRightRowSet3.rowCount()));
// verify results
RowSet actualRowSet = DirectRowSet.fromContainer(ljBatch.getContainer());
new RowSetComparison(expectedRowSet).verify(actualRowSet);
assertTrue(RecordBatch.IterOutcome.NONE == ljBatch.next());
} finally {
// Close all the resources for this test case
ljBatch.close();
leftMockBatch.close();
rightMockBatch.close();
nonEmptyRightRowSet2.clear();
expectedRowSet.clear();
}
}
use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.
the class TestLateralJoinCorrectnessBatchProcessing method testMultipleLeftAndRight_OutputFull_WithPendingLeftRow_LeftJoin.
@Test
public void testMultipleLeftAndRight_OutputFull_WithPendingLeftRow_LeftJoin() throws Exception {
// Get the right container with dummy data
final RowSet.SingleRowSet nonEmptyLeftRowSet2 = fixture.rowSetBuilder(leftSchema).addRow(5, 50, "item5").addRow(6, 60, "item6").build();
leftContainer.add(nonEmptyLeftRowSet.container());
leftContainer.add(nonEmptyLeftRowSet2.container());
// Get the left IterOutcomes for Lateral Join
leftOutcomes.add(RecordBatch.IterOutcome.OK_NEW_SCHEMA);
leftOutcomes.add(RecordBatch.IterOutcome.OK);
// Create Left MockRecordBatch
final CloseableRecordBatch leftMockBatch = new MockRecordBatch(fixture.getFragmentContext(), operatorContext, leftContainer, leftOutcomes, leftContainer.get(0).getSchema());
// Get the right container with dummy data
final RowSet.SingleRowSet nonEmptyRightRowSet2 = fixture.rowSetBuilder(rightSchema).addRow(1, 11, 110, "item11").addRow(2, 22, 220, "item22").build();
final RowSet.SingleRowSet expectedRowSet = fixture.rowSetBuilder(expectedSchemaLeftJoin).addRow(1, 10, "item1", 11, 110, "item11").addRow(2, 20, "item2", 22, 220, "item22").addRow(3, 30, "item3", null, null, null).build();
final RowSet.SingleRowSet expectedRowSet1 = fixture.rowSetBuilder(expectedSchemaLeftJoin).addRow(4, 40, "item4", null, null, null).addRow(5, 50, "item5", null, null, null).addRow(6, 60, "item6", null, null, null).build();
rightContainer.add(emptyRightRowSet.container());
rightContainer.add(nonEmptyRightRowSet2.container());
rightContainer.add(emptyRightRowSet.container());
rightOutcomes.add(RecordBatch.IterOutcome.OK_NEW_SCHEMA);
rightOutcomes.add(RecordBatch.IterOutcome.EMIT);
rightOutcomes.add(RecordBatch.IterOutcome.EMIT);
final CloseableRecordBatch rightMockBatch = new MockRecordBatch(fixture.getFragmentContext(), operatorContext, rightContainer, rightOutcomes, rightContainer.get(0).getSchema());
LateralJoinPOP ljPopConfig = new LateralJoinPOP(null, null, JoinRelType.LEFT, DrillLateralJoinRelBase.IMPLICIT_COLUMN, Lists.newArrayList());
final LateralJoinBatch ljBatch = new LateralJoinBatch(ljPopConfig, fixture.getFragmentContext(), leftMockBatch, rightMockBatch);
ljBatch.setMaxOutputRowCount(3);
ljBatch.setUseMemoryManager(false);
try {
assertTrue(RecordBatch.IterOutcome.OK_NEW_SCHEMA == ljBatch.next());
assertTrue(RecordBatch.IterOutcome.OK == ljBatch.next());
assertTrue(ljBatch.getRecordCount() == 3);
// verify results
RowSet actualRowSet = DirectRowSet.fromContainer(ljBatch.getContainer());
new RowSetComparison(expectedRowSet).verify(actualRowSet);
// Release output container memory for this batch as other operators will do
VectorAccessibleUtilities.clear(ljBatch);
assertTrue(RecordBatch.IterOutcome.OK == ljBatch.next());
assertTrue(ljBatch.getRecordCount() == (nonEmptyLeftRowSet.rowCount() + nonEmptyLeftRowSet2.rowCount() - 3));
// verify results
RowSet actualRowSet2 = DirectRowSet.fromContainer(ljBatch.getContainer());
new RowSetComparison(expectedRowSet1).verify(actualRowSet2);
assertTrue(RecordBatch.IterOutcome.NONE == ljBatch.next());
} finally {
// Close all the resources for this test case
ljBatch.close();
leftMockBatch.close();
rightMockBatch.close();
nonEmptyLeftRowSet2.clear();
nonEmptyRightRowSet2.clear();
expectedRowSet.clear();
expectedRowSet1.clear();
}
}
use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.
the class TestLateralJoinCorrectnessBatchProcessing method testLeftAndRightWithLastMissingRows_LeftJoin_MultipleBatch.
@Test
public void testLeftAndRightWithLastMissingRows_LeftJoin_MultipleBatch() throws Exception {
leftContainer.add(nonEmptyLeftRowSet.container());
// Get the left IterOutcomes for Lateral Join
leftOutcomes.add(RecordBatch.IterOutcome.OK_NEW_SCHEMA);
// Create Left MockRecordBatch
final CloseableRecordBatch leftMockBatch = new MockRecordBatch(fixture.getFragmentContext(), operatorContext, leftContainer, leftOutcomes, leftContainer.get(0).getSchema());
// Get the right container with dummy data
final RowSet.SingleRowSet nonEmptyRightRowSet2 = fixture.rowSetBuilder(rightSchema).addRow(1, 11, 110, "item11").addRow(2, 22, 220, "item22").build();
final RowSet.SingleRowSet nonEmptyRightRowSet3 = fixture.rowSetBuilder(rightSchema).addRow(3, 33, 330, "item33_1").addRow(3, 33, 330, "item33_2").build();
final RowSet.SingleRowSet expectedRowSet = fixture.rowSetBuilder(expectedSchemaLeftJoin).addRow(1, 10, "item1", 11, 110, "item11").addRow(2, 20, "item2", 22, 220, "item22").addRow(3, 30, "item3", 33, 330, "item33_1").addRow(3, 30, "item3", 33, 330, "item33_2").addRow(4, 40, "item4", null, null, null).build();
rightContainer.add(emptyRightRowSet.container());
rightContainer.add(nonEmptyRightRowSet2.container());
rightContainer.add(nonEmptyRightRowSet3.container());
rightOutcomes.add(RecordBatch.IterOutcome.OK_NEW_SCHEMA);
rightOutcomes.add(RecordBatch.IterOutcome.OK);
rightOutcomes.add(RecordBatch.IterOutcome.EMIT);
final CloseableRecordBatch rightMockBatch = new MockRecordBatch(fixture.getFragmentContext(), operatorContext, rightContainer, rightOutcomes, rightContainer.get(0).getSchema());
LateralJoinPOP ljPopConfig = new LateralJoinPOP(null, null, JoinRelType.LEFT, DrillLateralJoinRelBase.IMPLICIT_COLUMN, Lists.newArrayList());
final LateralJoinBatch ljBatch = new LateralJoinBatch(ljPopConfig, fixture.getFragmentContext(), leftMockBatch, rightMockBatch);
try {
assertTrue(RecordBatch.IterOutcome.OK_NEW_SCHEMA == ljBatch.next());
assertTrue(RecordBatch.IterOutcome.OK == ljBatch.next());
assertTrue(ljBatch.getRecordCount() == (1 + nonEmptyRightRowSet2.rowCount() + nonEmptyRightRowSet3.rowCount()));
// verify results
RowSet actualRowSet = DirectRowSet.fromContainer(ljBatch.getContainer());
new RowSetComparison(expectedRowSet).verify(actualRowSet);
assertTrue(RecordBatch.IterOutcome.NONE == ljBatch.next());
} finally {
// Close all the resources for this test case
ljBatch.close();
leftMockBatch.close();
rightMockBatch.close();
nonEmptyRightRowSet2.clear();
expectedRowSet.clear();
}
}
Aggregations