use of org.apache.drill.common.expression.FieldReference in project drill by apache.
the class TestSortEmitOutcome method defineOrdering.
@BeforeClass
public static void defineOrdering() {
String columnToSort = inputSchema.column(0).getName();
FieldReference expr = FieldReference.getWithQuotedRef(columnToSort);
Order.Ordering ordering = new Order.Ordering(Order.Ordering.ORDER_ASC, expr, Order.Ordering.NULLS_FIRST);
sortPopConfig = new ExternalSort(null, Lists.newArrayList(ordering), false);
}
use of org.apache.drill.common.expression.FieldReference in project drill by apache.
the class TestSortImpl method makeSortImpl.
/**
* Create the sort implementation to be used by test.
*
* @param fixture operator fixture
* @param sortOrder sort order as specified by {@link Ordering}
* @param nullOrder null order as specified by {@link Ordering}
* @return the initialized sort implementation, ready to do work
*/
public static SortImpl makeSortImpl(OperatorFixture fixture, String sortOrder, String nullOrder) {
FieldReference expr = FieldReference.getWithQuotedRef("key");
Ordering ordering = new Ordering(sortOrder, expr, nullOrder);
Sort popConfig = new Sort(null, Lists.newArrayList(ordering), false);
OperatorContext opContext = fixture.newOperatorContext(popConfig);
QueryId queryId = QueryId.newBuilder().setPart1(1234).setPart2(5678).build();
FragmentHandle handle = FragmentHandle.newBuilder().setMajorFragmentId(2).setMinorFragmentId(3).setQueryId(queryId).build();
SortConfig sortConfig = new SortConfig(opContext.getFragmentContext().getConfig(), opContext.getFragmentContext().getOptions());
SpillSet spillSet = new SpillSet(opContext.getFragmentContext().getConfig(), handle, popConfig);
PriorityQueueCopierWrapper copierHolder = new PriorityQueueCopierWrapper(opContext);
SpilledRuns spilledRuns = new SpilledRuns(opContext, spillSet, copierHolder);
dest = new VectorContainer(opContext.getAllocator());
return new SortImpl(opContext, sortConfig, spilledRuns, dest);
}
use of org.apache.drill.common.expression.FieldReference in project drill by apache.
the class TestSorter method makeSortConfig.
public static Sort makeSortConfig(String key, String sortOrder, String nullOrder) {
FieldReference expr = FieldReference.getWithQuotedRef(key);
Ordering ordering = new Ordering(sortOrder, expr, nullOrder);
return new Sort(null, Lists.newArrayList(ordering), false);
}
use of org.apache.drill.common.expression.FieldReference in project drill by apache.
the class SortTestUtilities method makeCopierConfig.
public static Sort makeCopierConfig(String sortOrder, String nullOrder) {
FieldReference expr = FieldReference.getWithQuotedRef("key");
Ordering ordering = new Ordering(sortOrder, expr, nullOrder);
return new Sort(null, Lists.newArrayList(ordering), false);
}
use of org.apache.drill.common.expression.FieldReference in project drill by apache.
the class TestOutputBatchSize method testNestedLoopJoinUpperLimit.
@Test
public void testNestedLoopJoinUpperLimit() throws Exception {
// test the upper limit of 65535 records per batch.
LogicalExpression functionCallExpr = new FunctionCall("<", ImmutableList.of((LogicalExpression) new FieldReference("c1", ExpressionPosition.UNKNOWN), (LogicalExpression) new FieldReference("c2", ExpressionPosition.UNKNOWN)), ExpressionPosition.UNKNOWN);
NestedLoopJoinPOP nestedLoopJoin = new NestedLoopJoinPOP(null, null, JoinRelType.INNER, functionCallExpr);
numRows = 500;
// create left input rows like this.
// "a1" : 5, "c1" : <id>
List<String> leftJsonBatches = Lists.newArrayList();
StringBuilder leftBatchString = new StringBuilder();
leftBatchString.append("[");
for (int i = 0; i < numRows; i++) {
leftBatchString.append("{\"a1\": 5, " + "\"c1\" : " + i + "},");
}
leftBatchString.append("{\"a1\": 5, " + "\"c1\" : " + numRows + "}");
leftBatchString.append("]");
leftJsonBatches.add(leftBatchString.toString());
// create right input rows like this.
// "a2" : 6, "c2" : <id>
List<String> rightJsonBatches = Lists.newArrayList();
StringBuilder rightBatchString = new StringBuilder();
rightBatchString.append("[");
for (int i = 0; i < numRows; i++) {
rightBatchString.append("{\"a2\": 6, " + "\"c2\" : " + i + "},");
}
rightBatchString.append("{\"a2\": 6, " + "\"c2\" : " + numRows + "}");
rightBatchString.append("]");
rightJsonBatches.add(rightBatchString.toString());
// output rows will be like this.
// "a1" : 5, "c1" : 1, "a2":6, "c2": 1
// "a1" : 5, "c1" : 2, "a2":6, "c2": 2
// "a1" : 5, "c1" : 3, "a2":6, "c2": 3
// we expect n(n+1)/2 number of records i.e. (500 * 501)/2 = 125250
// expect two batches, batch limited by 65535 records
LegacyOperatorTestBuilder opTestBuilder = legacyOpTestBuilder().physicalOperator(nestedLoopJoin).baselineColumns("a1", "c1", "a2", "c2").expectedNumBatches(// verify number of batches
2).inputDataStreamsJson(Lists.newArrayList(leftJsonBatches, rightJsonBatches));
for (long i = 0; i < numRows + 1; i++) {
for (long j = i + 1; j < numRows + 1; j++) {
opTestBuilder.baselineValues(5l, i, 6l, j);
}
}
opTestBuilder.go();
}
Aggregations