public void testWrongDateStr() throws HiveException { GenericUDFMonthsBetween udf = new GenericUDFMonthsBetween(); ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableStringObjectInspector; ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.writableStringObjectInspector; ObjectInspector[] arguments = {valueOI1, valueOI2}; udf.initialize(arguments); runTestStr("2002-03", "2002-02-24", null, udf); runTestStr("2002-03-24", "2002-02", null, udf); }
public void testMonthsBetweenForTimestamp() throws HiveException { GenericUDFMonthsBetween udf = new GenericUDFMonthsBetween(); ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableTimestampObjectInspector; ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.writableTimestampObjectInspector; ObjectInspector[] arguments = { valueOI1, valueOI2 }; udf.initialize(arguments); testMonthsBetweenForTimestamp(udf); // Run without round-off GenericUDFMonthsBetween udfWithoutRoundOff = new GenericUDFMonthsBetween(); ObjectInspector vOI1 = PrimitiveObjectInspectorFactory.writableTimestampObjectInspector; ObjectInspector vOI2 = PrimitiveObjectInspectorFactory.writableTimestampObjectInspector; ObjectInspector vOI3 = PrimitiveObjectInspectorFactory .getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.booleanTypeInfo, new BooleanWritable(false)); ObjectInspector[] args = { vOI1, vOI2, vOI3 }; udfWithoutRoundOff.initialize(args); testMonthsBetweenForTimestamp(udfWithoutRoundOff); }
public void testMonthsBetweenForDate() throws HiveException { GenericUDFMonthsBetween udf = new GenericUDFMonthsBetween(); ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableDateObjectInspector; ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.writableDateObjectInspector; ObjectInspector[] arguments = { valueOI1, valueOI2 }; udf.initialize(arguments); testMonthsBetweenForDate(udf); // Run without round-off GenericUDFMonthsBetween udfWithoutRoundOff = new GenericUDFMonthsBetween(); ObjectInspector vOI1 = PrimitiveObjectInspectorFactory.writableDateObjectInspector; ObjectInspector vOI2 = PrimitiveObjectInspectorFactory.writableDateObjectInspector; ObjectInspector vOI3 = PrimitiveObjectInspectorFactory .getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.booleanTypeInfo, new BooleanWritable(false)); ObjectInspector[] args = { vOI1, vOI2, vOI3 }; udfWithoutRoundOff.initialize(args); testMonthsBetweenForDate(udfWithoutRoundOff); }
public void testMonthsBetweenForString() throws HiveException { // Default run GenericUDFMonthsBetween udf = new GenericUDFMonthsBetween(); ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableStringObjectInspector; ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.writableStringObjectInspector; ObjectInspector[] arguments = { valueOI1, valueOI2 }; udf.initialize(arguments); testMonthsBetweenForString(udf); // Run without round-off GenericUDFMonthsBetween udfWithoutRoundOff = new GenericUDFMonthsBetween(); ObjectInspector vOI1 = PrimitiveObjectInspectorFactory.writableStringObjectInspector; ObjectInspector vOI2 = PrimitiveObjectInspectorFactory.writableStringObjectInspector; ObjectInspector vOI3 = PrimitiveObjectInspectorFactory .getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.booleanTypeInfo, new BooleanWritable(false)); ObjectInspector[] args = { vOI1, vOI2, vOI3 }; udfWithoutRoundOff.initialize(args); testMonthsBetweenForString(udf); }