> On Feb. 4, 2015, 11:13 p.m., Alexander Pivovarov wrote: > > ql/src/test/queries/clientnegative/udf_months_between_error1.q, line 1 > > <https://reviews.apache.org/r/30437/diff/2/?file=848940#file848940line1> > > > > valid query. result should be null but not error > > Jason Dere wrote: > Using the NULL constant is a bit of a special case, because NULL ends up > evaluating as VOID type. This is why the query ends up throwing an error > during query compile time (during initialize()), because the type doesn't > match. I wouldn't be surprised if most of the other date functions fail in > the same way during initialize(). On the other hand, MONTHS_BETWEEN(cast(null > as date), '2012-03-01') should not get an error (though it should return null > result). > > So this might be a bad example to use in the test - rather than > MONTHS_BETWEEN(null, '2012-03-01'), use a different expression such as > MONTHS_BETWEEN(1, '2012-03-01'), it looks a little less confusing.
probably MONTHS_BETWEEN(1, '2012-03-01') and MONTHS_BETWEEN('2012-03-01', 1) are better. Error should say smth like expect STRING/TIMESTAMP got INT - Alexander ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/30437/#review71066 ----------------------------------------------------------- On Feb. 4, 2015, 10:30 p.m., XIAOBING ZHOU wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/30437/ > ----------------------------------------------------------- > > (Updated Feb. 4, 2015, 10:30 p.m.) > > > Review request for hive. > > > Repository: hive-git > > > Description > ------- > > This is used to track work to build Oracle like months_between. Here's > semantics: > MONTHS_BETWEEN returns number of months between dates date1 and date2. If > date1 is later than date2, then the result is positive. If date1 is earlier > than date2, then the result is negative. If date1 and date2 are either the > same days of the month or both last days of months, then the result is always > an integer. Otherwise Oracle Database calculates the fractional portion of > the result based on a 31-day month and considers the difference in time > components date1 and date2. > > https://issues.apache.org/jira/browse/HIVE-9518 > > > Diffs > ----- > > ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java bfb4dc2 > ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFDateDiff.java > 1ecd835 > > ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFDateDiffBase.java > PRE-CREATION > > ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFMonthsBetween.java > PRE-CREATION > ql/src/test/org/apache/hadoop/hive/ql/udf/TestGenericUDFMonthsBetween.java > PRE-CREATION > ql/src/test/queries/clientnegative/udf_months_between_error1.q PRE-CREATION > ql/src/test/queries/clientnegative/udf_months_between_error2.q PRE-CREATION > ql/src/test/queries/clientnegative/udf_months_between_error3.q PRE-CREATION > ql/src/test/queries/clientnegative/udf_months_between_error4.q PRE-CREATION > ql/src/test/queries/clientnegative/udf_months_between_error5.q PRE-CREATION > ql/src/test/queries/clientnegative/udf_months_between_error6.q PRE-CREATION > ql/src/test/queries/clientnegative/udf_months_between_error7.q PRE-CREATION > ql/src/test/queries/clientnegative/udf_months_between_error8.q PRE-CREATION > ql/src/test/queries/clientnegative/udf_months_between_error9.q PRE-CREATION > ql/src/test/queries/clientpositive/udf_months_between.q PRE-CREATION > ql/src/test/results/clientnegative/udf_months_between_error1.q.out > PRE-CREATION > ql/src/test/results/clientnegative/udf_months_between_error2.q.out > PRE-CREATION > ql/src/test/results/clientnegative/udf_months_between_error3.q.out > PRE-CREATION > ql/src/test/results/clientnegative/udf_months_between_error4.q.out > PRE-CREATION > ql/src/test/results/clientnegative/udf_months_between_error5.q.out > PRE-CREATION > ql/src/test/results/clientnegative/udf_months_between_error6.q.out > PRE-CREATION > ql/src/test/results/clientnegative/udf_months_between_error7.q.out > PRE-CREATION > ql/src/test/results/clientnegative/udf_months_between_error8.q.out > PRE-CREATION > ql/src/test/results/clientnegative/udf_months_between_error9.q.out > PRE-CREATION > ql/src/test/results/clientpositive/show_functions.q.out e21b54b > ql/src/test/results/clientpositive/udf_months_between.q.out PRE-CREATION > > Diff: https://reviews.apache.org/r/30437/diff/ > > > Testing > ------- > > SEE ALSO ql/src/test/TestGenericUDFMonthsBetween.java > > > Thanks, > > XIAOBING ZHOU > >