use of org.apache.hadoop.hive.serde2.io.TimestampWritable in project hive by apache.
the class GenericUDFReflect2 method evaluate.
@Override
public Object evaluate(DeferredObject[] arguments) throws HiveException {
Object targetObject = targetOI.getPrimitiveJavaObject(arguments[0].get());
if (targetObject == null) {
return null;
}
Object result = null;
try {
result = method.invoke(targetObject, setupParameters(arguments, 2));
} catch (InvocationTargetException e) {
throw new HiveException(e.getCause());
} catch (Exception e) {
throw new HiveException(e);
}
if (result == null) {
return null;
}
switch(returnOI.getPrimitiveCategory()) {
case VOID:
return null;
case BOOLEAN:
((BooleanWritable) returnObj).set((Boolean) result);
return returnObj;
case BYTE:
((ByteWritable) returnObj).set((Byte) result);
return returnObj;
case SHORT:
((ShortWritable) returnObj).set((Short) result);
return returnObj;
case INT:
((IntWritable) returnObj).set((Integer) result);
return returnObj;
case LONG:
((LongWritable) returnObj).set((Long) result);
return returnObj;
case FLOAT:
((FloatWritable) returnObj).set((Float) result);
return returnObj;
case DOUBLE:
((DoubleWritable) returnObj).set((Double) result);
return returnObj;
case STRING:
((Text) returnObj).set((String) result);
return returnObj;
case TIMESTAMP:
((TimestampWritable) returnObj).set((Timestamp) result);
return returnObj;
case BINARY:
((BytesWritable) returnObj).set((byte[]) result, 0, ((byte[]) result).length);
return returnObj;
case DECIMAL:
((HiveDecimalWritable) returnObj).set((HiveDecimal) result);
return returnObj;
}
throw new HiveException("Invalid type " + returnOI.getPrimitiveCategory());
}
use of org.apache.hadoop.hive.serde2.io.TimestampWritable in project hive by apache.
the class TestVectorTimestampExpressions method compareToUDFDayOfMonthLong.
private void compareToUDFDayOfMonthLong(Timestamp t, int y) {
UDFDayOfMonth udf = new UDFDayOfMonth();
TimestampWritable tsw = new TimestampWritable(t);
IntWritable res = udf.evaluate(tsw);
Assert.assertEquals(res.get(), y);
}
use of org.apache.hadoop.hive.serde2.io.TimestampWritable in project hive by apache.
the class TestVectorTimestampExpressions method compareToUDFHourLong.
private void compareToUDFHourLong(Timestamp t, int y) {
UDFHour udf = new UDFHour();
TimestampWritable tsw = new TimestampWritable(t);
IntWritable res = udf.evaluate(tsw);
Assert.assertEquals(res.get(), y);
}
use of org.apache.hadoop.hive.serde2.io.TimestampWritable in project hive by apache.
the class TestVectorTimestampExpressions method compareToUDFSecondLong.
private void compareToUDFSecondLong(Timestamp t, int y) {
UDFSecond udf = new UDFSecond();
TimestampWritable tsw = new TimestampWritable(t);
IntWritable res = udf.evaluate(tsw);
Assert.assertEquals(res.get(), y);
}
use of org.apache.hadoop.hive.serde2.io.TimestampWritable in project hive by apache.
the class TestVectorTimestampExpressions method compareToUDFWeekOfYearLong.
private void compareToUDFWeekOfYearLong(Timestamp t, int y) {
UDFWeekOfYear udf = new UDFWeekOfYear();
TimestampWritable tsw = new TimestampWritable(t);
IntWritable res = udf.evaluate(tsw);
Assert.assertEquals(res.get(), y);
}
Aggregations