Skip to content

Instantly share code, notes, and snippets.

@chbatey
Last active October 22, 2018 18:40
Show Gist options
  • Save chbatey/55e559408f6016bd72db to your computer and use it in GitHub Desktop.
Save chbatey/55e559408f6016bd72db to your computer and use it in GitHub Desktop.
CREATE OR REPLACE FUNCTION state_group_and_count( state map<text, int>, type text )
CALLED ON NULL INPUT
RETURNS map<text, int>
LANGUAGE java AS '
Integer count = (Integer) state.get(type); if (count == null) count = 1; else count++; state.put(type, count); return state; ' ;
CREATE OR REPLACE AGGREGATE group_and_count(text)
SFUNC state_group_and_count
STYPE map<text, int>
INITCOND {};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment