use of org.apache.hadoop.hbase.io.ImmutableBytesWritable in project phoenix by apache.
the class CoerceExpressionTest method testCoerceExpressionSupportsCoercingAllPDataTypesToVarBinary.
@Test
public void testCoerceExpressionSupportsCoercingAllPDataTypesToVarBinary() throws Exception {
for (PDataType p : PDataType.values()) {
if (!p.isArrayType()) {
LiteralExpression v = LiteralExpression.newConstant(map.get(p.getJavaClass()), p);
CoerceExpression e = new CoerceExpression(v, PVarbinary.INSTANCE);
ImmutableBytesWritable ptr = new ImmutableBytesWritable();
e.evaluate(null, ptr);
Object obj = e.getDataType().toObject(ptr);
assertTrue("Coercing to VARBINARY failed for PDataType " + p, obj instanceof byte[]);
}
}
}
use of org.apache.hadoop.hbase.io.ImmutableBytesWritable in project phoenix by apache.
the class CoerceExpressionTest method testCoerceExpressionSupportsCoercingAllPDataTypesToBinary.
@Test
public void testCoerceExpressionSupportsCoercingAllPDataTypesToBinary() throws Exception {
for (PDataType p : PDataType.values()) {
if (!p.isArrayType()) {
LiteralExpression v = LiteralExpression.newConstant(map.get(p.getJavaClass()), p);
CoerceExpression e = new CoerceExpression(v, PBinary.INSTANCE);
ImmutableBytesWritable ptr = new ImmutableBytesWritable();
e.evaluate(null, ptr);
Object obj = e.getDataType().toObject(ptr);
assertTrue("Coercing to BINARY failed for PDataType " + p, obj instanceof byte[]);
}
}
}
use of org.apache.hadoop.hbase.io.ImmutableBytesWritable in project phoenix by apache.
the class CoerceExpressionTest method testCoerceExpressionSupportsCoercingCharToVarchar.
@Test
public void testCoerceExpressionSupportsCoercingCharToVarchar() throws Exception {
LiteralExpression v = LiteralExpression.newConstant("a", PChar.INSTANCE);
CoerceExpression e = new CoerceExpression(v, PVarchar.INSTANCE);
ImmutableBytesWritable ptr = new ImmutableBytesWritable();
e.evaluate(null, ptr);
Object obj = e.getDataType().toObject(ptr);
assertTrue(obj instanceof String);
String value = (String) obj;
assertTrue(value.equals("a"));
}
use of org.apache.hadoop.hbase.io.ImmutableBytesWritable in project phoenix by apache.
the class CoerceExpressionTest method testCoerceExpressionSupportsCoercingIntToLong.
@Test
public void testCoerceExpressionSupportsCoercingIntToLong() throws Exception {
LiteralExpression v = LiteralExpression.newConstant(1, PInteger.INSTANCE);
CoerceExpression e = new CoerceExpression(v, PLong.INSTANCE);
ImmutableBytesWritable ptr = new ImmutableBytesWritable();
e.evaluate(null, ptr);
Object obj = e.getDataType().toObject(ptr);
assertTrue(obj instanceof Long);
Long value = (Long) obj;
assertTrue(value.equals(Long.valueOf(1)));
}
use of org.apache.hadoop.hbase.io.ImmutableBytesWritable in project phoenix by apache.
the class CoerceExpressionTest method testCoerceExpressionSupportsCoercingIntToDecimal.
@Test
public void testCoerceExpressionSupportsCoercingIntToDecimal() throws Exception {
LiteralExpression v = LiteralExpression.newConstant(1, PInteger.INSTANCE);
CoerceExpression e = new CoerceExpression(v, PDecimal.INSTANCE);
ImmutableBytesWritable ptr = new ImmutableBytesWritable();
e.evaluate(null, ptr);
Object obj = e.getDataType().toObject(ptr);
assertTrue(obj instanceof BigDecimal);
BigDecimal value = (BigDecimal) obj;
assertTrue(value.equals(BigDecimal.valueOf(1)));
}
Aggregations