use of org.apache.drill.exec.expr.holders.VarCharHolder in project drill by axbaretto.
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.toString(DrillFileUtils.getResourceAsFile("/functions/cast/testCastVarChar.json"), Charsets.UTF_8));
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 axbaretto.
the class TestByteComparisonFunctions method testEqualCompareLong.
@Test
public void testEqualCompareLong() {
final VarCharHolder left = helloLong;
final VarCharHolder right = helloLong;
assertTrue(ByteFunctionHelpers.compare(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 axbaretto.
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 axbaretto.
the class TestByteComparisonFunctions method testNotEqual.
@Test
public void testNotEqual() {
final VarCharHolder left = hello;
final VarCharHolder right = goodbye;
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 axbaretto.
the class TestByteComparisonFunctions method testEqualCompare.
@Test
public void testEqualCompare() {
final VarCharHolder left = hello;
final VarCharHolder right = hello;
assertTrue(ByteFunctionHelpers.compare(left.buffer, left.start, left.end, right.buffer, right.start, right.end) == 0);
}
Aggregations