commit | ffec1e25e51b0e43eeee2d9627d9b890ed00fcb3 | [log] [tgz] |
---|---|---|
author | Makoto Yui <myui@apache.org> | Wed Oct 23 18:01:51 2019 +0900 |
committer | Makoto Yui <myui@apache.org> | Wed Oct 23 18:01:51 2019 +0900 |
tree | 0e80c7502d4b60d27cecb7f0bc63cd8e85f79fc3 | |
parent | 0c7ba1734006a69b3173758b7a7106a835b3c6c2 [diff] |
[HIVEMALL-261][HIVEMALL-262] argmin/argmax/argsort UDF ## What changes were proposed in this pull request? Introduce argmin/argmax/argsort UDF ## What type of PR is it? Feature ## What is the Jira issue? https://issues.apache.org/jira/browse/HIVEMALL-261 https://issues.apache.org/jira/browse/HIVEMALL-262 ## How was this patch tested? unit tests, manual tests on EMR ## How to use this feature? ```sql SELECT argmax(array(5,2,0,1)); > 0 SELECT array_slice(array(5,2,0,1), argmax(array(5,2,0,1))); > 5 SELECT argmin(array(5,2,0,1)); > 2 SELECT argsort(array(5,2,0,1)); > 2, 3, 1, 0 SELECT array_slice(array(5,2,0,1), argsort(array(5,2,0,1))); > 0, 1, 2, 5 SELECT argsort(argsort(array(5,2,0,1))), argrank(array(5,2,0,1)); > 3, 2, 0, 1 SELECT arange(5), arange(1, 5), arange(1, 5, 1), arange(0, 5, 1); > [0,1,2,3,4] [1,2,3,4] [1,2,3,4] [0,1,2,3,4] SELECT arange(1, 6, 2); > 1, 3, 5 SELECT arange(-1, -6, 2); > -1, -3, -5 SELECT argsort(array(5, 2, 0, 1)), argrank(array(5, 2, 0, 1)), argsort(argsort(array(5, 2, 0, 1))); > [2,3,1,0] [3,2,0,1] [3,2,0,1] ``` ## Checklist (Please remove this section if not needed; check `x` for YES, blank for NO) - [x] Did you apply source code formatter, i.e., `./bin/format_code.sh`, for your commit? - [ ] Did you run system tests on Hive (or Spark)? Author: Makoto Yui <myui@apache.org> Closes #197 from myui/argmax.
Apache Hivemall is a scalable machine learning library that runs on Apache Hive, Apache Spark, and Apache Pig. Hivemall is designed to be scalable to the number of training instances as well as the number of training features.
Find more examples on our user guide and find a brief introduction to Hivemall in this slide.
Support is through user@hivemall.incubator.apache.org, not by a direct e-mail.
If you are planning to contribute to this repository, we first request you to create an issue at our JIRA page even if the topic is not related to source code itself (e.g., documentation, new idea and proposal).
All Hivemall functions are defined under resources/ddl. In order to update the definition files, the following script helps inserting function name and class path of your new UDF:
$ ./bin/update_ddls.sh
Moreover, don't forget to update function list in the document as well:
$ ./bin/update_func_md.sh
Note that, before creating a pull request including Java code, please make sure your code follows our coding conventions by applying formatter:
$ ./bin/format_code.sh