Skip to content

Instantly share code, notes, and snippets.

@randyzwitch
Created December 16, 2013 20:21
Show Gist options
  • Save randyzwitch/7993686 to your computer and use it in GitHub Desktop.
Save randyzwitch/7993686 to your computer and use it in GitHub Desktop.
Example hive query
-- This will give me back a text file for every reducer, then I need to cat * > outfile to get a single text file
-- Feels like there should be a simple setting to tell Hive that I want a single text file back
--query_history
insert overwrite local directory '/tmp/hive/old_backup/query_history'
select
to_date(from_unixtime(CAST(created as int))) as query_date,
account_code,
audit_key,
entity_code,
provider_code,
count(token) as records
from query_history
group by to_date(from_unixtime(CAST(created as int))), account_code, audit_key, entity_code, provider_code;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment