zohar
zohar

Reputation: 2378

Hive: how to retrieve data by row timestamp

I am using hive to run select queries on HBase tables.

I want to retrieve all rows where with timestamp value lower then X.

My question is how to created select query like this (should I need to create the Hive table in particular way?)

Upvotes: 2

Views: 2014

Answers (3)

Carter Shore
Carter Shore

Reputation: 1

I believe that the OP is seeking the ability to select rows from a table whose create timestamp matches a condition.
AFAIK, Hive does not expose this.
The two functions above are for converting a given timestamp values (which are interpreted as UTC) to and from a given timezones.

Upvotes: 0

Case
Case

Reputation: 937

According to this Quora thread, two timestamp functions are available in Hive 0.8:

from_utc_timestamp(timestamp, string timezone)

to_utc_timestamp(timestamp, string timezone).

Upvotes: 1

David
David

Reputation: 3261

Timestamp is an attribute associated with a column value. Unless Hive has a specific convention called out in the documentation to make column timestamps explicitly available, I doubt you can access the timestamp information from Hive.

In HBase, you can construct a scan and add a filter condition for the timestamp. There is a example that you can base such a filter off in the code: /hbase/src/main/java/org/apache/hadoop/hbase/filter/TimestampsFilter.java

Note: you have to make sure that your code is in the classpath of every regionserver before this will work. Which implies that you will have to restart your regionservers.

Upvotes: 2

Related Questions