Created
July 31, 2015 01:23
-
-
Save ogibayashi/4c68bff95176beaaaaff to your computer and use it in GitHub Desktop.
Norikra上でマスタデータ等とJOINするのに使えるnorikra-udf-lookupを作った ref: http://qiita.com/ogibayashi/items/67b37904cae3b47cf407
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'norikra-udf-lookup' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ gem install norikra-udf-lookup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% cat /tmp/lookuptest.tsv | |
1 aaa | |
2 bbb | |
3 ccc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
id, lookup_tsv('/tmp/lookuptest.tsv',id,'not found') as name, count(*) as cnt | |
FROM | |
test_stream.win:time_batch(1 min) | |
GROUP by id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% echo '{"id":"1"}' | norikra-client event send test_stream | |
% echo '{"id":"2"}' | norikra-client event send test_stream | |
% echo '{"id":"3"}' | norikra-client event send test_stream | |
% echo '{"id":"4"}' | norikra-client event send test_stream |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% norikra-client event sweep | |
{"time":"2015/07/28 12:13:24","query":"lookuptest","id":"3","cnt":1,"name":"ccc"} | |
{"time":"2015/07/28 12:13:24","query":"lookuptest","id":"2","cnt":1,"name":"bbb"} | |
{"time":"2015/07/28 12:13:24","query":"lookuptest","id":"1","cnt":1,"name":"aaa"} | |
{"time":"2015/07/28 12:13:24","query":"lookuptest","id":"4","cnt":1,"name":"not found"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment