Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
+ "Returns the date that is num_months after start_date.",
extended = "start_date is a string or timestamp indicating a valid date. "
+ "num_months is a number. output_date_format is an optional String which specifies the format for output.\n"
+ "The default output format is 'YYYY-MM-dd'.\n"
+ "The default output format is 'yyyy-MM-dd'.\n"
+ "Example:\n > SELECT _FUNC_('2009-08-31', 1) FROM src LIMIT 1;\n" + " '2009-09-30'."
+ "\n > SELECT _FUNC_('2017-12-31 14:15:16', 2, 'YYYY-MM-dd HH:mm:ss') LIMIT 1;\n"
+ "\n > SELECT _FUNC_('2017-12-31 14:15:16', 2, 'yyyy-MM-dd HH:mm:ss') LIMIT 1;\n"
+ "'2018-02-28 14:15:16'.\n")
@NDV(maxNdv = 250) // 250 seems to be reasonable upper limit for this
public class GenericUDFAddMonths extends GenericUDF {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
*/
public class TestGenericUDFAddMonths {

private final Text fmtTextWithTime = new Text("YYYY-MM-dd HH:mm:ss");
private final Text fmtTextWithTimeAndms = new Text("YYYY-MM-dd HH:mm:ss.SSS");
private final Text fmtTextWithoutTime = new Text("YYYY-MM-dd");
private final Text fmtTextInvalid = new Text("YYYY-abcdz");
private final Text fmtTextWithTime = new Text("yyyy-MM-dd HH:mm:ss");
private final Text fmtTextWithTimeAndms = new Text("yyyy-MM-dd HH:mm:ss.SSS");
private final Text fmtTextWithoutTime = new Text("yyyy-MM-dd");
private final Text fmtTextInvalid = new Text("yyyy-abcdz");

@Test
public void testAddMonthsInt() throws HiveException {
Expand Down
4 changes: 2 additions & 2 deletions ql/src/test/results/clientpositive/llap/udf_add_months.q.out
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ POSTHOOK: query: DESCRIBE FUNCTION EXTENDED add_months
POSTHOOK: type: DESCFUNCTION
add_months(start_date, num_months, output_date_format) - Returns the date that is num_months after start_date.
start_date is a string or timestamp indicating a valid date. num_months is a number. output_date_format is an optional String which specifies the format for output.
The default output format is 'YYYY-MM-dd'.
The default output format is 'yyyy-MM-dd'.
Example:
> SELECT add_months('2009-08-31', 1) FROM src LIMIT 1;
'2009-09-30'.
> SELECT add_months('2017-12-31 14:15:16', 2, 'YYYY-MM-dd HH:mm:ss') LIMIT 1;
> SELECT add_months('2017-12-31 14:15:16', 2, 'yyyy-MM-dd HH:mm:ss') LIMIT 1;
'2018-02-28 14:15:16'.

Function class:org.apache.hadoop.hive.ql.udf.generic.GenericUDFAddMonths
Expand Down