private void compareToUDFMonthLong(Timestamp t, int y) throws HiveException { UDFMonth udf = new UDFMonth(); 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 compareToUDFMonthDate(long t, int y) throws HiveException { UDFMonth udf = new UDFMonth(); 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); }