use of org.apache.drill.exec.proto.BitControl.QueryContextInformation in project drill by apache.
the class TestLocalExchange method testHelperVerifyPartitionSenderParallelization.
// Verify the number of partition senders in a major fragments is not more than the cluster size and each endpoint
// in the cluster has at most one fragment from a given major fragment that has the partition sender.
private static void testHelperVerifyPartitionSenderParallelization(String plan, boolean isMuxOn, boolean isDeMuxOn) throws Exception {
final DrillbitContext drillbitContext = getDrillbitContext();
final PhysicalPlanReader planReader = drillbitContext.getPlanReader();
final Fragment rootFragment = PopUnitTestBase.getRootFragmentFromPlanString(planReader, plan);
final List<Integer> deMuxFragments = Lists.newLinkedList();
final List<Integer> htrFragments = Lists.newLinkedList();
final PlanningSet planningSet = new PlanningSet();
// Create a planningSet to get the assignment of major fragment ids to fragments.
PARALLELIZER.initFragmentWrappers(rootFragment, planningSet);
findFragmentsWithPartitionSender(rootFragment, planningSet, deMuxFragments, htrFragments);
final QueryContextInformation queryContextInfo = Utilities.createQueryContextInfo("dummySchemaName", "938ea2d9-7cb9-4baf-9414-a5a0b7777e8e");
QueryWorkUnit qwu = PARALLELIZER.generateWorkUnit(new OptionList(), drillbitContext.getEndpoint(), QueryId.getDefaultInstance(), drillbitContext.getBits(), rootFragment, USER_SESSION, queryContextInfo);
qwu.applyPlan(planReader);
// Make sure the number of minor fragments with HashPartitioner within a major fragment is not more than the
// number of Drillbits in cluster
ArrayListMultimap<Integer, DrillbitEndpoint> partitionSenderMap = ArrayListMultimap.create();
for (PlanFragment planFragment : qwu.getFragments()) {
if (planFragment.getFragmentJson().contains("hash-partition-sender")) {
int majorFragmentId = planFragment.getHandle().getMajorFragmentId();
DrillbitEndpoint assignedEndpoint = planFragment.getAssignment();
partitionSenderMap.get(majorFragmentId).add(assignedEndpoint);
}
}
if (isMuxOn) {
verifyAssignment(htrFragments, partitionSenderMap);
}
if (isDeMuxOn) {
verifyAssignment(deMuxFragments, partitionSenderMap);
}
}
use of org.apache.drill.exec.proto.BitControl.QueryContextInformation in project drill by apache.
the class ExpressionInterpreterTest method interpreterDateTest.
@Test
public void interpreterDateTest() throws Exception {
final String[] colNames = { "col1" };
final TypeProtos.MajorType[] colTypes = { Types.optional(TypeProtos.MinorType.INT) };
final String expressionStr = "now()";
final BitControl.PlanFragment planFragment = BitControl.PlanFragment.getDefaultInstance();
final QueryContextInformation queryContextInfo = planFragment.getContext();
final int timeZoneIndex = queryContextInfo.getTimeZone();
final DateTimeZone timeZone = DateTimeZone.forID(org.apache.drill.exec.expr.fn.impl.DateUtility.getTimeZone(timeZoneIndex));
final org.joda.time.DateTime now = new org.joda.time.DateTime(queryContextInfo.getQueryStartTime(), timeZone);
final long queryStartDate = now.getMillis();
final TimeStampHolder out = new TimeStampHolder();
out.value = queryStartDate;
final ByteBuffer buffer = ByteBuffer.allocate(12);
buffer.putLong(out.value);
final long l = buffer.getLong(0);
final LocalDateTime t = Instant.ofEpochMilli(l).atZone(ZoneOffset.systemDefault()).toLocalDateTime();
final String[] expectedFirstTwoValues = { t.toString(), t.toString() };
doTest(expressionStr, colNames, colTypes, expectedFirstTwoValues, planFragment);
}
use of org.apache.drill.exec.proto.BitControl.QueryContextInformation in project drill by apache.
the class TestFragmentChecker method print.
private void print(String fragmentFile, int bitCount, int expectedFragmentCount) throws Exception {
PhysicalPlanReader ppr = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(CONFIG);
Fragment fragmentRoot = getRootFragment(ppr, fragmentFile);
SimpleParallelizer par = new DefaultQueryParallelizer(true, 1000 * 1000, 5, 10, 1.2);
List<DrillbitEndpoint> endpoints = Lists.newArrayList();
DrillbitEndpoint localBit = null;
for (int i = 0; i < bitCount; i++) {
DrillbitEndpoint b1 = DrillbitEndpoint.newBuilder().setAddress("localhost").setControlPort(1234 + i).build();
if (i == 0) {
localBit = b1;
}
endpoints.add(b1);
}
final QueryContextInformation queryContextInfo = Utilities.createQueryContextInfo("dummySchemaName", "938ea2d9-7cb9-4baf-9414-a5a0b7777e8e");
QueryWorkUnit qwu = par.generateWorkUnit(new OptionList(), localBit, QueryId.getDefaultInstance(), endpoints, fragmentRoot, UserSession.Builder.newBuilder().withCredentials(UserBitShared.UserCredentials.newBuilder().setUserName("foo").build()).build(), queryContextInfo);
qwu.applyPlan(ppr);
assertEquals(expectedFragmentCount, qwu.getFragments().size() + 1);
}
Aggregations