FAQ
Author: jdere
Date: Tue Apr 7 22:39:59 2015
New Revision: 1671965

URL: http://svn.apache.org/r1671965
Log:
HIVE-10044: Allow interval params for year/month/day/hour/minute/second functions (Jason Dere, reviewed by Thejas Nair)

Added:
     hive/trunk/ql/src/test/queries/clientpositive/interval_udf.q
     hive/trunk/ql/src/test/results/clientpositive/interval_udf.q.out
Modified:
     hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFDayOfMonth.java
     hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFHour.java
     hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFMinute.java
     hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFMonth.java
     hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFSecond.java
     hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFYear.java
     hive/trunk/ql/src/test/results/clientpositive/udf_day.q.out
     hive/trunk/ql/src/test/results/clientpositive/udf_dayofmonth.q.out
     hive/trunk/ql/src/test/results/clientpositive/udf_hour.q.out
     hive/trunk/ql/src/test/results/clientpositive/udf_minute.q.out
     hive/trunk/ql/src/test/results/clientpositive/udf_month.q.out
     hive/trunk/ql/src/test/results/clientpositive/udf_second.q.out

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFDayOfMonth.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFDayOfMonth.java?rev=1671965&r1=1671964&r2=1671965&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFDayOfMonth.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFDayOfMonth.java Tue Apr 7 22:39:59 2015
@@ -29,6 +29,7 @@ import org.apache.hadoop.hive.ql.exec.ve
  import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorUDFDayOfMonthLong;
  import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorUDFDayOfMonthString;
  import org.apache.hadoop.hive.serde2.io.DateWritable;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalDayTimeWritable;
  import org.apache.hadoop.hive.serde2.io.TimestampWritable;
  import org.apache.hadoop.io.IntWritable;
  import org.apache.hadoop.io.Text;
@@ -38,9 +39,12 @@ import org.apache.hadoop.io.Text;
   *
   */
  @Description(name = "day,dayofmonth",
- value = "_FUNC_(date) - Returns the date of the month of date",
- extended = "date is a string in the format of 'yyyy-MM-dd HH:mm:ss' or "
- + "'yyyy-MM-dd'.\n"
+ value = "_FUNC_(param) - Returns the day of the month of date/timestamp, or day component of interval",
+ extended = "param can be one of:\n"
+ + "1. A string in the format of 'yyyy-MM-dd HH:mm:ss' or 'yyyy-MM-dd'.\n"
+ + "2. A date value\n"
+ + "3. A timestamp value\n"
+ + "4. A day-time interval value"
      + "Example:\n "
      + " > SELECT _FUNC_('2009-07-30') FROM src LIMIT 1;\n" + " 30")
  @VectorizedExpressions({VectorUDFDayOfMonthLong.class, VectorUDFDayOfMonthString.class})
@@ -98,4 +102,12 @@ public class UDFDayOfMonth extends UDF {
      return result;
    }

+ public IntWritable evaluate(HiveIntervalDayTimeWritable i) {
+ if (i == null) {
+ return null;
+ }
+
+ result.set(i.getHiveIntervalDayTime().getDays());
+ return result;
+ }
  }

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFHour.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFHour.java?rev=1671965&r1=1671964&r2=1671965&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFHour.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFHour.java Tue Apr 7 22:39:59 2015
@@ -28,6 +28,7 @@ import org.apache.hadoop.hive.ql.exec.UD
  import org.apache.hadoop.hive.ql.exec.vector.VectorizedExpressions;
  import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorUDFHourLong;
  import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorUDFHourString;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalDayTimeWritable;
  import org.apache.hadoop.hive.serde2.io.TimestampWritable;
  import org.apache.hadoop.io.IntWritable;
  import org.apache.hadoop.io.Text;
@@ -37,9 +38,11 @@ import org.apache.hadoop.io.Text;
   *
   */
  @Description(name = "hour",
- value = "_FUNC_(date) - Returns the hour of date",
- extended = "date is a string in the format of 'yyyy-MM-dd HH:mm:ss' or "
- + "'HH:mm:ss'.\n"
+ value = "_FUNC_(param) - Returns the hour componemnt of the string/timestamp/interval",
+ extended ="param can be one of:\n"
+ + "1. A string in the format of 'yyyy-MM-dd HH:mm:ss' or 'HH:mm:ss'.\n"
+ + "2. A timestamp value\n"
+ + "3. A day-time interval value"
      + "Example:\n "
      + " > SELECT _FUNC_('2009-07-30 12:58:59') FROM src LIMIT 1;\n"
      + " 12\n"
@@ -95,4 +98,12 @@ public class UDFHour extends UDF {
      return result;
    }

+ public IntWritable evaluate(HiveIntervalDayTimeWritable i) {
+ if (i == null) {
+ return null;
+ }
+
+ result.set(i.getHiveIntervalDayTime().getHours());
+ return result;
+ }
  }

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFMinute.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFMinute.java?rev=1671965&r1=1671964&r2=1671965&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFMinute.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFMinute.java Tue Apr 7 22:39:59 2015
@@ -28,6 +28,7 @@ import org.apache.hadoop.hive.ql.exec.UD
  import org.apache.hadoop.hive.ql.exec.vector.VectorizedExpressions;
  import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorUDFMinuteLong;
  import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorUDFMinuteString;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalDayTimeWritable;
  import org.apache.hadoop.hive.serde2.io.TimestampWritable;
  import org.apache.hadoop.io.IntWritable;
  import org.apache.hadoop.io.Text;
@@ -37,9 +38,11 @@ import org.apache.hadoop.io.Text;
   *
   */
  @Description(name = "minute",
- value = "_FUNC_(date) - Returns the minute of date",
- extended = "date is a string in the format of 'yyyy-MM-dd HH:mm:ss' or "
- + "'HH:mm:ss'.\n"
+ value = "_FUNC_(param) - Returns the minute component of the string/timestamp/interval",
+ extended = "param can be one of:\n"
+ + "1. A string in the format of 'yyyy-MM-dd HH:mm:ss' or 'HH:mm:ss'.\n"
+ + "2. A timestamp value\n"
+ + "3. A day-time interval value"
      + "Example:\n "
      + " > SELECT _FUNC_('2009-07-30 12:58:59') FROM src LIMIT 1;\n"
      + " 58\n"
@@ -95,4 +98,12 @@ public class UDFMinute extends UDF {
      return result;
    }

+ public IntWritable evaluate(HiveIntervalDayTimeWritable i) {
+ if (i == null) {
+ return null;
+ }
+
+ result.set(i.getHiveIntervalDayTime().getMinutes());
+ return result;
+ }
  }

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFMonth.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFMonth.java?rev=1671965&r1=1671964&r2=1671965&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFMonth.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFMonth.java Tue Apr 7 22:39:59 2015
@@ -29,6 +29,7 @@ import org.apache.hadoop.hive.ql.exec.ve
  import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorUDFMonthLong;
  import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorUDFMonthString;
  import org.apache.hadoop.hive.serde2.io.DateWritable;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalYearMonthWritable;
  import org.apache.hadoop.hive.serde2.io.TimestampWritable;
  import org.apache.hadoop.io.IntWritable;
  import org.apache.hadoop.io.Text;
@@ -38,8 +39,13 @@ import org.apache.hadoop.io.Text;
   *
   */
  @Description(name = "month",
- value = "_FUNC_(date) - Returns the month of date",
- extended = "Example:\n"
+ value = "_FUNC_(param) - Returns the month component of the date/timestamp/interval",
+ extended = "param can be one of:\n"
+ + "1. A string in the format of 'yyyy-MM-dd HH:mm:ss' or 'yyyy-MM-dd'.\n"
+ + "2. A date value\n"
+ + "3. A timestamp value\n"
+ + "4. A year-month interval value"
+ + "Example:\n"
      + " > SELECT _FUNC_('2009-07-30') FROM src LIMIT 1;\n" + " 7")
  @VectorizedExpressions({VectorUDFMonthLong.class, VectorUDFMonthString.class})
  public class UDFMonth extends UDF {
@@ -94,4 +100,12 @@ public class UDFMonth extends UDF {
      return result;
    }

+ public IntWritable evaluate(HiveIntervalYearMonthWritable i) {
+ if (i == null) {
+ return null;
+ }
+
+ result.set(i.getHiveIntervalYearMonth().getMonths());
+ return result;
+ }
  }

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFSecond.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFSecond.java?rev=1671965&r1=1671964&r2=1671965&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFSecond.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFSecond.java Tue Apr 7 22:39:59 2015
@@ -23,23 +23,29 @@ import java.text.SimpleDateFormat;
  import java.util.Calendar;
  import java.util.Date;

+import org.apache.hadoop.hive.common.type.HiveIntervalDayTime;
  import org.apache.hadoop.hive.ql.exec.Description;
  import org.apache.hadoop.hive.ql.exec.UDF;
  import org.apache.hadoop.hive.ql.exec.vector.VectorizedExpressions;
  import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorUDFSecondLong;
  import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorUDFSecondString;
+import org.apache.hadoop.hive.serde2.io.DoubleWritable;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalDayTimeWritable;
  import org.apache.hadoop.hive.serde2.io.TimestampWritable;
  import org.apache.hadoop.io.IntWritable;
  import org.apache.hadoop.io.Text;
+import org.apache.hive.common.util.DateUtils;

  /**
   * UDFSecond.
   *
   */
  @Description(name = "second",
- value = "_FUNC_(date) - Returns the second of date",
- extended = "date is a string in the format of 'yyyy-MM-dd HH:mm:ss' or "
- + "'HH:mm:ss'.\n"
+ value = "_FUNC_(date) - Returns the second component of the string/timestamp/interval",
+ extended = "param can be one of:\n"
+ + "1. A string in the format of 'yyyy-MM-dd HH:mm:ss' or 'HH:mm:ss'.\n"
+ + "2. A timestamp value\n"
+ + "3. A day-time interval value"
      + "Example:\n "
      + " > SELECT _FUNC_('2009-07-30 12:58:59') FROM src LIMIT 1;\n"
      + " 59\n"
@@ -96,4 +102,13 @@ public class UDFSecond extends UDF {
      return result;
    }

+ public IntWritable evaluate(HiveIntervalDayTimeWritable i) {
+ if (i == null) {
+ return null;
+ }
+
+ HiveIntervalDayTime idt = i.getHiveIntervalDayTime();
+ result.set(idt.getSeconds());
+ return result;
+ }
  }

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFYear.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFYear.java?rev=1671965&r1=1671964&r2=1671965&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFYear.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFYear.java Tue Apr 7 22:39:59 2015
@@ -29,6 +29,7 @@ import org.apache.hadoop.hive.ql.exec.ve
  import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorUDFYearLong;
  import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorUDFYearString;
  import org.apache.hadoop.hive.serde2.io.DateWritable;
+import org.apache.hadoop.hive.serde2.io.HiveIntervalYearMonthWritable;
  import org.apache.hadoop.hive.serde2.io.TimestampWritable;
  import org.apache.hadoop.io.IntWritable;
  import org.apache.hadoop.io.Text;
@@ -38,9 +39,12 @@ import org.apache.hadoop.io.Text;
   *
   */
  @Description(name = "year",
- value = "_FUNC_(date) - Returns the year of date",
- extended = "date is a string in the format of 'yyyy-MM-dd HH:mm:ss' or "
- + "'yyyy-MM-dd'.\n"
+ value = "_FUNC_(param) - Returns the year component of the date/timestamp/interval",
+ extended = "param can be one of:\n"
+ + "1. A string in the format of 'yyyy-MM-dd HH:mm:ss' or 'yyyy-MM-dd'.\n"
+ + "2. A date value\n"
+ + "3. A timestamp value\n"
+ + "4. A year-month interval value"
      + "Example:\n "
      + " > SELECT _FUNC_('2009-07-30') FROM src LIMIT 1;\n" + " 2009")
  @VectorizedExpressions({VectorUDFYearLong.class, VectorUDFYearString.class})
@@ -98,4 +102,12 @@ public class UDFYear extends UDF {
      return result;
    }

+ public IntWritable evaluate(HiveIntervalYearMonthWritable i) {
+ if (i == null) {
+ return null;
+ }
+
+ result.set(i.getHiveIntervalYearMonth().getYears());
+ return result;
+ }
  }

Added: hive/trunk/ql/src/test/queries/clientpositive/interval_udf.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/interval_udf.q?rev=1671965&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/interval_udf.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/interval_udf.q Tue Apr 7 22:39:59 2015
@@ -0,0 +1,8 @@
+
+select
+ year(iym), month(iym), day(idt), hour(idt), minute(idt), second(idt)
+from (
+ select interval '1-2' year to month iym, interval '3 4:5:6.789' day to second idt
+ from src limit 1
+) q;
+

Added: hive/trunk/ql/src/test/results/clientpositive/interval_udf.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/interval_udf.q.out?rev=1671965&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/interval_udf.q.out (added)
+++ hive/trunk/ql/src/test/results/clientpositive/interval_udf.q.out Tue Apr 7 22:39:59 2015
@@ -0,0 +1,19 @@
+PREHOOK: query: select
+ year(iym), month(iym), day(idt), hour(idt), minute(idt), second(idt)
+from (
+ select interval '1-2' year to month iym, interval '3 4:5:6.789' day to second idt
+ from src limit 1
+) q
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: select
+ year(iym), month(iym), day(idt), hour(idt), minute(idt), second(idt)
+from (
+ select interval '1-2' year to month iym, interval '3 4:5:6.789' day to second idt
+ from src limit 1
+) q
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+1 2 3 4 5 6

Modified: hive/trunk/ql/src/test/results/clientpositive/udf_day.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/udf_day.q.out?rev=1671965&r1=1671964&r2=1671965&view=diff
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/udf_day.q.out (original)
+++ hive/trunk/ql/src/test/results/clientpositive/udf_day.q.out Tue Apr 7 22:39:59 2015
@@ -2,14 +2,17 @@ PREHOOK: query: DESCRIBE FUNCTION day
  PREHOOK: type: DESCFUNCTION
  POSTHOOK: query: DESCRIBE FUNCTION day
  POSTHOOK: type: DESCFUNCTION
-day(date) - Returns the date of the month of date
+day(param) - Returns the day of the month of date/timestamp, or day component of interval
  PREHOOK: query: DESCRIBE FUNCTION EXTENDED day
  PREHOOK: type: DESCFUNCTION
  POSTHOOK: query: DESCRIBE FUNCTION EXTENDED day
  POSTHOOK: type: DESCFUNCTION
-day(date) - Returns the date of the month of date
+day(param) - Returns the day of the month of date/timestamp, or day component of interval
  Synonyms: dayofmonth
-date is a string in the format of 'yyyy-MM-dd HH:mm:ss' or 'yyyy-MM-dd'.
-Example:
+param can be one of:
+1. A string in the format of 'yyyy-MM-dd HH:mm:ss' or 'yyyy-MM-dd'.
+2. A date value
+3. A timestamp value
+4. A day-time interval valueExample:
SELECT day('2009-07-30') FROM src LIMIT 1;
    30

Modified: hive/trunk/ql/src/test/results/clientpositive/udf_dayofmonth.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/udf_dayofmonth.q.out?rev=1671965&r1=1671964&r2=1671965&view=diff
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/udf_dayofmonth.q.out (original)
+++ hive/trunk/ql/src/test/results/clientpositive/udf_dayofmonth.q.out Tue Apr 7 22:39:59 2015
@@ -2,14 +2,17 @@ PREHOOK: query: DESCRIBE FUNCTION dayofm
  PREHOOK: type: DESCFUNCTION
  POSTHOOK: query: DESCRIBE FUNCTION dayofmonth
  POSTHOOK: type: DESCFUNCTION
-dayofmonth(date) - Returns the date of the month of date
+dayofmonth(param) - Returns the day of the month of date/timestamp, or day component of interval
  PREHOOK: query: DESCRIBE FUNCTION EXTENDED dayofmonth
  PREHOOK: type: DESCFUNCTION
  POSTHOOK: query: DESCRIBE FUNCTION EXTENDED dayofmonth
  POSTHOOK: type: DESCFUNCTION
-dayofmonth(date) - Returns the date of the month of date
+dayofmonth(param) - Returns the day of the month of date/timestamp, or day component of interval
  Synonyms: day
-date is a string in the format of 'yyyy-MM-dd HH:mm:ss' or 'yyyy-MM-dd'.
-Example:
+param can be one of:
+1. A string in the format of 'yyyy-MM-dd HH:mm:ss' or 'yyyy-MM-dd'.
+2. A date value
+3. A timestamp value
+4. A day-time interval valueExample:
SELECT dayofmonth('2009-07-30') FROM src LIMIT 1;
    30

Modified: hive/trunk/ql/src/test/results/clientpositive/udf_hour.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/udf_hour.q.out?rev=1671965&r1=1671964&r2=1671965&view=diff
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/udf_hour.q.out (original)
+++ hive/trunk/ql/src/test/results/clientpositive/udf_hour.q.out Tue Apr 7 22:39:59 2015
@@ -2,14 +2,16 @@ PREHOOK: query: DESCRIBE FUNCTION hour
  PREHOOK: type: DESCFUNCTION
  POSTHOOK: query: DESCRIBE FUNCTION hour
  POSTHOOK: type: DESCFUNCTION
-hour(date) - Returns the hour of date
+hour(param) - Returns the hour componemnt of the string/timestamp/interval
  PREHOOK: query: DESCRIBE FUNCTION EXTENDED hour
  PREHOOK: type: DESCFUNCTION
  POSTHOOK: query: DESCRIBE FUNCTION EXTENDED hour
  POSTHOOK: type: DESCFUNCTION
-hour(date) - Returns the hour of date
-date is a string in the format of 'yyyy-MM-dd HH:mm:ss' or 'HH:mm:ss'.
-Example:
+hour(param) - Returns the hour componemnt of the string/timestamp/interval
+param can be one of:
+1. A string in the format of 'yyyy-MM-dd HH:mm:ss' or 'HH:mm:ss'.
+2. A timestamp value
+3. A day-time interval valueExample:
SELECT hour('2009-07-30 12:58:59') FROM src LIMIT 1; 12
SELECT hour('12:58:59') FROM src LIMIT 1;
Modified: hive/trunk/ql/src/test/results/clientpositive/udf_minute.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/udf_minute.q.out?rev=1671965&r1=1671964&r2=1671965&view=diff
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/udf_minute.q.out (original)
+++ hive/trunk/ql/src/test/results/clientpositive/udf_minute.q.out Tue Apr 7 22:39:59 2015
@@ -2,14 +2,16 @@ PREHOOK: query: DESCRIBE FUNCTION minute
  PREHOOK: type: DESCFUNCTION
  POSTHOOK: query: DESCRIBE FUNCTION minute
  POSTHOOK: type: DESCFUNCTION
-minute(date) - Returns the minute of date
+minute(param) - Returns the minute component of the string/timestamp/interval
  PREHOOK: query: DESCRIBE FUNCTION EXTENDED minute
  PREHOOK: type: DESCFUNCTION
  POSTHOOK: query: DESCRIBE FUNCTION EXTENDED minute
  POSTHOOK: type: DESCFUNCTION
-minute(date) - Returns the minute of date
-date is a string in the format of 'yyyy-MM-dd HH:mm:ss' or 'HH:mm:ss'.
-Example:
+minute(param) - Returns the minute component of the string/timestamp/interval
+param can be one of:
+1. A string in the format of 'yyyy-MM-dd HH:mm:ss' or 'HH:mm:ss'.
+2. A timestamp value
+3. A day-time interval valueExample:
SELECT minute('2009-07-30 12:58:59') FROM src LIMIT 1; 58
SELECT minute('12:58:59') FROM src LIMIT 1;
Modified: hive/trunk/ql/src/test/results/clientpositive/udf_month.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/udf_month.q.out?rev=1671965&r1=1671964&r2=1671965&view=diff
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/udf_month.q.out (original)
+++ hive/trunk/ql/src/test/results/clientpositive/udf_month.q.out Tue Apr 7 22:39:59 2015
@@ -2,14 +2,16 @@ PREHOOK: query: DESCRIBE FUNCTION minute
  PREHOOK: type: DESCFUNCTION
  POSTHOOK: query: DESCRIBE FUNCTION minute
  POSTHOOK: type: DESCFUNCTION
-minute(date) - Returns the minute of date
+minute(param) - Returns the minute component of the string/timestamp/interval
  PREHOOK: query: DESCRIBE FUNCTION EXTENDED minute
  PREHOOK: type: DESCFUNCTION
  POSTHOOK: query: DESCRIBE FUNCTION EXTENDED minute
  POSTHOOK: type: DESCFUNCTION
-minute(date) - Returns the minute of date
-date is a string in the format of 'yyyy-MM-dd HH:mm:ss' or 'HH:mm:ss'.
-Example:
+minute(param) - Returns the minute component of the string/timestamp/interval
+param can be one of:
+1. A string in the format of 'yyyy-MM-dd HH:mm:ss' or 'HH:mm:ss'.
+2. A timestamp value
+3. A day-time interval valueExample:
SELECT minute('2009-07-30 12:58:59') FROM src LIMIT 1; 58
SELECT minute('12:58:59') FROM src LIMIT 1;
Modified: hive/trunk/ql/src/test/results/clientpositive/udf_second.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/udf_second.q.out?rev=1671965&r1=1671964&r2=1671965&view=diff
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/udf_second.q.out (original)
+++ hive/trunk/ql/src/test/results/clientpositive/udf_second.q.out Tue Apr 7 22:39:59 2015
@@ -2,14 +2,16 @@ PREHOOK: query: DESCRIBE FUNCTION second
  PREHOOK: type: DESCFUNCTION
  POSTHOOK: query: DESCRIBE FUNCTION second
  POSTHOOK: type: DESCFUNCTION
-second(date) - Returns the second of date
+second(date) - Returns the second component of the string/timestamp/interval
  PREHOOK: query: DESCRIBE FUNCTION EXTENDED second
  PREHOOK: type: DESCFUNCTION
  POSTHOOK: query: DESCRIBE FUNCTION EXTENDED second
  POSTHOOK: type: DESCFUNCTION
-second(date) - Returns the second of date
-date is a string in the format of 'yyyy-MM-dd HH:mm:ss' or 'HH:mm:ss'.
-Example:
+second(date) - Returns the second component of the string/timestamp/interval
+param can be one of:
+1. A string in the format of 'yyyy-MM-dd HH:mm:ss' or 'HH:mm:ss'.
+2. A timestamp value
+3. A day-time interval valueExample:
SELECT second('2009-07-30 12:58:59') FROM src LIMIT 1; 59
SELECT second('12:58:59') FROM src LIMIT 1;

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcommits @
categorieshive, hadoop
postedApr 7, '15 at 10:40p
activeApr 7, '15 at 10:40p
posts1
users1
websitehive.apache.org

1 user in discussion

Jdere: 1 post

People

Translate

site design / logo © 2021 Grokbase