Two questions:
1. How would one group by week (instead of date or time)?
My first idea was the following:
INSERT OVERWRITE TABLE platforms_weekly select platform, count(distinct
apikey), count(1), date_add(pdate, datediff('2007-12-31', pdate) / 7)
from shairlogs group by platform, datediff('2007-12-31', pdate) / 7
but the issue is that Hive can't know there's a subcalculation that is
the same in both group part and output part.
I tried to use AS statement with group expression, but no luck there [or
maybe I didn't know how].
2. When grouping by months there seems to be a problem of getting the
proper 'yyyy-mm' as part of output columns.
Here my idea was:
INSERT OVERWRITE TABLE platforms_monthly select platform, count(distinct
apikey), count(1), concat(concat(CAST(year(pdate) as STRING), '-'),
CAST(month(pdate) as STRING)) from shairlogs group by platform,
year(pdate), month(pdate)"
But the issue is that output yyyy-mm strings are not zero-padded for
months and lexical sort then breaks on them...
--
Andraz Tori, CTO
Zemanta Ltd, New York, London, Ljubljana
www.zemanta.com
mail: [email protected]
tel: +386 41 515 767
twitter: andraz, skype: minmax_test