private void compareToUDFYearLong(Timestamp t, int y) throws HiveException { UDFYear udf = new UDFYear(); udf.initialize(new ObjectInspector[]{PrimitiveObjectInspectorFactory.writableTimestampObjectInspector}); TimestampWritableV2 tsw = new TimestampWritableV2( org.apache.hadoop.hive.common.type.Timestamp.ofEpochMilli(t.getTime(), t.getNanos())); IntWritable res = (IntWritable) udf.evaluate( new GenericUDF.DeferredObject[]{new GenericUDF.DeferredJavaObject(tsw)}); Assert.assertEquals(res.get(), y); }
private void compareToUDFYearDate(long t, int y) throws HiveException { UDFYear udf = new UDFYear(); udf.initialize(new ObjectInspector[]{PrimitiveObjectInspectorFactory.writableTimestampObjectInspector}); TimestampWritableV2 tsw = toTimestampWritable(t); IntWritable res = (IntWritable) udf.evaluate( new GenericUDF.DeferredObject[]{new GenericUDF.DeferredJavaObject(tsw)}); Assert.assertEquals(res.get(), y); }