AnsweredAssumed Answered

how to give unique numbers to records in mysql and hive

Question asked by venu on Jun 23, 2014
Hi

I have sample data and data looks like:

sensor     time stamp           tag name   value     quality
unit_1  31-Dec-2012 00:52:00   TAG1      999.877     196608
unit_1  31-Dec-2012 00:53:00   TAG1      999.456       -1
unit_1  31-Dec-2012 00:54:00   TAG1      999.688     196608

I want to load this data into HIVE and at the same time i need to give unique numbers like serial_numbers.

Expected output:

serial_number  sensor     time stamp         tag name   value     quality
1             unit_1  31-Dec-2012 00:52:00   TAG1      999.877     196608
2             unit_1  31-Dec-2012 00:53:00   TAG1      999.456       -1
3             unit_1  31-Dec-2012 00:54:00   TAG1      999.688     196608


After loading data into HIVE i need to calculate  difference in timestamp and value if quality= -1.

Expected output:

difference in time stamp (00:54:00 - 00:52:00)/difference in value(999.688 - 999.877).

Could you please let me know the code for these two expected output.

Thnaks

Outcomes