Hi sir, I would advise utilizing HIVE date functions: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-DateFunctions
For example, you can extract hour from your logtime column using following
function:
* int hour(string date) Returns the hour of the timestamp:
hour('2009-07-30 12:58:59') = 12, hour('12:58:59') = 12
Jarcec
On Mon, Jun 25, 2012 at 01:08:16PM +0530, Soham Sardar wrote:
> hey jerec ,
>
> this is my hive description for my sample table users_audit
>
> hive> desc users_audit;
> OK
> id int
> userid int
> logtime string
> Time taken: 0.341 seconds
> hive>
>
> and this is my mysql description for the same table
>
> mysql> desc users_audit;
> +---------+----------+------+-----+---------+----------------+
> | Field | Type | Null | Key | Default | Extra |
> +---------+----------+------+-----+---------+----------------+
> | id | int(6) | NO | PRI | NULL | auto_increment |
> | userid | int(6) | NO | MUL | NULL | |
> | logtime | datetime | YES | | NULL | |
> +---------+----------+------+-----+---------+----------------+
> 3 rows in set (0.00 sec)
>
>
> now temme how can i query userid of the users between 10 am to 11am
> of their loggin time (the log time contains the log in time of each
> user )
>
>
> On Mon, Jun 25, 2012 at 1:00 PM, Jarek Jarcec Cecho <[email protected]> wrote:
> > Hi sir,
> > I'm having difficulties to understand your question. Could you please share
> > with us your MySQL table scheme, used sqoop import command and query that
> > you want to run in Hive?
> >
> > Jarcec
> >
> > On Mon, Jun 25, 2012 at 12:53:29PM +0530, Soham Sardar wrote:
> >> i have a problem with querying with the datetime format of mysql and
> >> then it has to stored in the string format and nothing else and then
> >> when i try to query in it say name the users who logged between 10 to
> >> 11 am in time coz i am using LIKE which matches pattern and then i
> >> cant give like for all the time instances ... can some one help me out
> >> with this as to how to implement these types of querying both in HIVE
> >> and mySql
signature.asc
Description: Digital signature
