GitHub user HeartSaVioR opened a pull request:
https://github.com/apache/storm/pull/1633
STORM-1434 Support the GROUP BY clause in StormSQL
* Support GROUP BY for Trident
* Implement basic functions for aggregation
* Change the way of converting Calcite logical plan to Trident logical plan
** before: creating codes and compile them
** after: use Trident features, only creating code block if evaluation is
needed
*** Janino comes in to help evaluating code block in runtime
This change can handle the below sql statements in runtime:
```
CREATE EXTERNAL TABLE ORDERS (ID INT PRIMARY KEY, UNIT_PRICE INT, QUANTITY
INT) LOCATION 'kafka://localhost:2181/brokers?topic=orders' TBLPROPERTIES
'{"producer":{"bootstrap.servers":"localhost:9092","acks":"1","key.serializer":"org.apache.storm.kafka.IntSerializer","value.serializer":"org.apache.storm.kafka.ByteBufferSerializer"}}'
CREATE EXTERNAL TABLE LARGE_ORDERS (ID INT PRIMARY KEY, TOTAL INT) LOCATION
'kafka://localhost:2181/brokers?topic=large_orders' TBLPROPERTIES
'{"producer":{"bootstrap.servers":"localhost:9092","acks":"1","key.serializer":"org.apache.storm.kafka.IntSerializer","value.serializer":"org.apache.storm.kafka.ByteBufferSerializer"}}'
INSERT INTO LARGE_ORDERS SELECT ID, UNIT_PRICE * QUANTITY AS TOTAL FROM
ORDERS WHERE UNIT_PRICE * QUANTITY > 50
```
```
CREATE EXTERNAL TABLE ORDERS (ID INT PRIMARY KEY, UNIT_PRICE INT, QUANTITY
INT) LOCATION 'kafka://localhost:2181/brokers?topic=orders' TBLPROPERTIES
'{"producer":{"bootstrap.servers":"localhost:9092","acks":"1","key.serializer":"org.apache.storm.kafka.IntSerializer","value.serializer":"org.apache.storm.kafka.ByteBufferSerializer"}}'
CREATE EXTERNAL TABLE SUMMARY_ORDERS (ID INT PRIMARY KEY, UNIT_PRICE_AVG
DOUBLE, SUM_OF_QUANTITY INT) LOCATION
'kafka://localhost:2181/brokers?topic=large_orders' TBLPROPERTIES
'{"producer":{"bootstrap.servers":"localhost:9092","acks":"1","key.serializer":"org.apache.storm.kafka.IntSerializer","value.serializer":"org.apache.storm.kafka.ByteBufferSerializer"}}'
INSERT INTO SUMMARY_ORDERS SELECT ID, AVG(UNIT_PRICE) AS UNIT_PRICE_AVG,
SUM(QUANTITY) AS SUM_OF_QUANTITY FROM ORDERS GROUP BY ID
```
This can be easily backported to 1.x branch since it only touches storm-sql
module.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/HeartSaVioR/storm STORM-1454
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/storm/pull/1633.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #1633
----
commit fc93fdad03c25967e7b00cc9c2289f46d71fb0a9
Author: Jungtaek Lim <[email protected]>
Date: 2016-08-18T07:32:46Z
STORM-1434 Support the GROUP BY clause in StormSQL
* Support GROUP BY for Trident
* Implement basic functions for aggregation
* Change the way of converting Calcite logical plan to Trident logical plan
** before: creating codes and compile them
** after: use Trident features, only creating code block if evaluation is
needed
*** Janino comes in to help evaluating code block in runtime
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---