hive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Santlal J Gupta <Santlal.Gu...@bitwiseglobal.com>
Subject Issue while working with Date
Date Mon, 27 Jul 2015 06:17:49 GMT
Hi,

I am beginner with working in hive.
I have one issue.
I have seen the source code of hive_master. In that source code there is one class named Date_Writable.
In this class there is get and set method. One of set method tatking int  as argument.


  public DateWritable(int d) {
    set(d);
  }

  /**
   * Set the DateWritable based on the days since epoch date.
   * @param d integer value representing days since epoch date
   */
  public void set(int d) {
    daysSinceEpoch = d;
  }

  /**
   * Set the DateWritable based on the year/month/day of the date in the local timezone.
   * @param d Date value
   */
  public void set(Date d) {
    if (d == null) {
      daysSinceEpoch = 0;
      return;
    }

    set(dateToDays(d));
  }

  public void set(DateWritable d) {
    set(d.daysSinceEpoch);
  }

And there is one of method named get which will return the daysSinceEpoch

public int getDays() {
    return daysSinceEpoch;
  }

So my query is that if I pass the daysSinceEpoch as value to date column so it should take
it.
For this I have written following query.

Query :

hive (primitive_type)> create table dateDemo(data Date) ;
OK
Time taken: 0.296 seconds

hive (primitive_type)> insert into dateDemo values(50);
OK
Time taken: 24.529 seconds

hive (primitive_type)> select * from dateDemo;
OK
NULL
Time taken: 0.168 seconds, Fetched: 1 row(s)

So can I insert epochDays in the date type column. So that when I read the column I will get
actual date.
Please guide me for this issue.

Thanks,
Santlal J. Gupta




**************************************Disclaimer******************************************
This e-mail message and any attachments may contain confidential information and is for the
sole use of the intended recipient(s) only. Any views or opinions presented or implied are
solely those of the author and do not necessarily represent the views of BitWise. If you are
not the intended recipient(s), you are hereby notified that disclosure, printing, copying,
forwarding, distribution, or the taking of any action whatsoever in reliance on the contents
of this electronic information is strictly prohibited. If you have received this e-mail message
in error, please immediately notify the sender and delete the electronic message and any attachments.BitWise
does not accept liability for any virus introduced by this e-mail or any attachments. ********************************************************************************************

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message