use of org.apache.drill.exec.expr.holders.VarCharHolder in project drill by apache.
the class TestCastFunctions method testCastVarChar.
@Test
public // cast to varchar(length)
void testCastVarChar() throws Throwable {
final DrillbitContext bitContext = mockDrillbitContext();
final UserClientConnection connection = Mockito.mock(UserClientConnection.class);
final PhysicalPlanReader reader = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(CONFIG);
final PhysicalPlan plan = reader.readPhysicalPlan(Files.asCharSource(DrillFileUtils.getResourceAsFile("/functions/cast/testCastVarChar.json"), Charsets.UTF_8).read());
final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(CONFIG);
final FragmentContextImpl context = new FragmentContextImpl(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));
while (exec.next()) {
final VarCharVector c0 = exec.getValueVectorById(new SchemaPath("int_lit_cast", ExpressionPosition.UNKNOWN), VarCharVector.class);
final VarCharVector.Accessor a0 = c0.getAccessor();
int count = 0;
for (int i = 0; i < c0.getAccessor().getValueCount(); i++) {
final VarCharHolder holder0 = new VarCharHolder();
a0.get(i, holder0);
assertEquals("123", StringFunctionHelpers.toStringFromUTF8(holder0.start, holder0.end, holder0.buffer));
++count;
}
assertEquals(5, count);
}
exec.close();
context.close();
if (context.getExecutorState().getFailureCause() != null) {
throw context.getExecutorState().getFailureCause();
}
assertTrue(!context.getExecutorState().isFailed());
}
use of org.apache.drill.exec.expr.holders.VarCharHolder in project drill by apache.
the class TestByteComparisonFunctions method testNotEqualLong.
@Test
public void testNotEqualLong() {
final VarCharHolder left = helloLong;
final VarCharHolder right = goodbyeLong;
assertTrue(ByteFunctionHelpers.equal(left.buffer, left.start, left.end, right.buffer, right.start, right.end) == 0);
}
use of org.apache.drill.exec.expr.holders.VarCharHolder in project drill by apache.
the class TestByteComparisonFunctions method testEqualLong.
@Test
public void testEqualLong() {
final VarCharHolder left = helloLong;
final VarCharHolder right = helloLong;
assertTrue(ByteFunctionHelpers.equal(left.buffer, left.start, left.end, right.buffer, right.start, right.end) == 1);
}
use of org.apache.drill.exec.expr.holders.VarCharHolder in project drill by apache.
the class TestByteComparisonFunctions method testAfterLong.
@Test
public void testAfterLong() {
final VarCharHolder left = helloLong;
final VarCharHolder right = goodbyeLong;
assertTrue(ByteFunctionHelpers.compare(left.buffer, left.start, left.end, right.buffer, right.start, right.end) == 1);
}
use of org.apache.drill.exec.expr.holders.VarCharHolder in project drill by apache.
the class TestByteComparisonFunctions method testAfter.
@Test
public void testAfter() {
final VarCharHolder left = hello;
final VarCharHolder right = goodbye;
assertTrue(ByteFunctionHelpers.compare(left.buffer, left.start, left.end, right.buffer, right.start, right.end) == 1);
}
Aggregations